NancyFx/Nancy — Issue #408: Exception during rendering kills SelfHost
Author: lnmx
Created: 2011-11-16 18:00:45+00:00
State: open

Using 0.9.0 with SelfHost, this code produces a 500 error response as expected:

Get[ "/foo" ] = delegate { throw new Exception( "foo" ); };

When the exception is delayed to output time, it generates an unhandled exception that kills the process:

Get[ "/bar" ] = _ => new HtmlResponse( contents: delegate { throw new Exception( "bar" ); } );

Can this be handled any better?

Incidentally, the original issue I had was referencing a non-existant Layout from a Razor view, yielding a `NullReferenceException` in `RazorViewEngine.GetOrCompileView()`