Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get real error messages in Nancy on Mono?

I can't figure out how to get actual 500 errors to be written into the response body. All I get is the Nancy 500 error page with JavaScript button to show the error. Since this is all happening behind the scenes via an iOS application I can't view the error, and in fact Nancy does not render the error to the div at all.

Is there some wonky self-hosting configuration to just let the runtime stacktrace get inserted into the response? (Obviously just while we are debugging).

In normal ASP it would be easy to limit debugging to localhost. Anyway, I feel kind of blind coding in Nancy and only being able to debug with Visual Studio. All the responses come from within a standard route handler/ controller module.

I'd like to avoid having to sprinkle everything with try catches and just let things fail and get real errors when things fail.

like image 868
FlavorScape Avatar asked Mar 11 '13 23:03

FlavorScape


1 Answers

Implement your own IStatusCodeHandler and handle 500 return codes. If you need to, you can also override the OnError pipeline to get access to the actual exception (you can read about this in the documentation).

Detailed information, on the error page, is shown when built in debug mode. For some reason it does not appear to show it for you. What you could do is force it to always be enabled by setting in code:

StaticConfiguration.DisableErrorTraces = false

like image 64
TheCodeJunkie Avatar answered Oct 20 '22 22:10

TheCodeJunkie