Skip to content

Instantly share code, notes, and snippets.

@JefClaes
Created December 23, 2012 23:21
Show Gist options
  • Save JefClaes/4366674 to your computer and use it in GitHub Desktop.
Save JefClaes/4366674 to your computer and use it in GitHub Desktop.
Quick-and-dirty errorhandler
public class LoggingErrorHandler : IErrorHandler
{
public void Handle(Nancy.HttpStatusCode statusCode, Nancy.NancyContext context)
{
object error;
var gotException = context.Items.TryGetValue(NancyEngine.ERROR_EXCEPTION, out error);
if (!gotException)
return;
using (var session = DocumentStore.Get().OpenSession())
{
session.Store(new { StatusCode = statusCode, Error = error as Exception });
session.SaveChanges();
}
}
public bool HandlesStatusCode(Nancy.HttpStatusCode statusCode, Nancy.NancyContext context)
{
return true;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment