Response ConvertToHttpResponse(NancyContext ctx, Exception err) { string contentType = ctx.Request.Headers.ContentType; IExceptionRepackager handler = _config.ErrorHandlers.FirstOrDefault(x => x.CanHandle(err, contentType)); Response response = handler == null ? _config.DefaultExceptionRepackager.Repackage(err, ctx, contentType) : handler.Repackage(err, ctx, contentType); _config.ResponseAction(response); return(response); }
public RestExceptionConfiguration WithDefault(IExceptionRepackager handler) { DefaultExceptionRepackager = handler; return(this); }
public RestExceptionConfiguration WithRepackager(IExceptionRepackager handler) { ErrorHandlers.Add(handler); return(this); }