I'm trying to get my self-hosted service using Nancy to return json formatted errors upon an uncaught exception. However, I am always getting the response:

{"readyState":4,"status":404,"statusText":"error"}


(below is the amalgamation of several examples across the net).

My bootstrapper contains the following:

        pipelines.OnError.AddItemToEndOfPipeline((ctx, exc) =&gt;
        {
            if (exc is Exception)
            {
                // this is always executed upon failure to handle an exception.

                Log.Error("Unhandled error on request: " + context.Request.Url + " : " + exc.Message, exc);

                JsonResponse response = new JsonResponse(string.Format("{0}:{1}", exc, exc.Message), new DefaultJsonSerializer());
                response.StatusCode = HttpStatusCode.InternalServerError;

                return response;
            }

            return HttpStatusCode.InternalServerError;
        });


I have a StatusCodeHandler:

public class JsonErrorStatusCodeHandler : IStatusCodeHandler
{
    public bool HandlesStatusCode(HttpStatusCode statusCode, NancyContext context)
    {
        return statusCode == HttpStatusCode.InternalServerError;
    }


    public void Handle(HttpStatusCode statusCode, NancyContext context)
    {
        var exception = context.GetException();

        if (exception != null)
        {
            // never executed
        }

        // this is executed

        JsonResponse response = new JsonResponse("wtf"), new DefaultJsonSerializer());
        response.StatusCode = HttpStatusCode.InternalServerError;

        context.Response = response;
    }


Although I've verified that the code in OnError and Handle is executed (see comments), my clients still receive 404. I've also tried using 

        var exception = context.Items[NancyEngine.ERROR_EXCEPTION] as Exception;


instead of 

        var exception = context.GetException();


with no luck.


Question: Install old version of Wine
Answer: I suspect the information on that page that mentions a wine version from 2004 is extremely old (over 10 years old). The compatibility box at the top of the page suggests it works fine on the latest versions of wine.

If you are having a problem running it on the current version of wine in Ubuntu, the best thing to do would be to file a bug report with any crash details and with a description of the problem.