Created
December 23, 2012 23:21
-
-
Save JefClaes/4366674 to your computer and use it in GitHub Desktop.
Quick-and-dirty errorhandler
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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