Releases: josephwoodward/GlobalExceptionHandlerDotNet
Test title
4.0.3 Clean up
4.0.2 Release
#31 - Fix where response was being returned before task finishes which resulted in the responses having no content by alek-mcgarry
4.0.1 Release
Fix for #28
4.0.0 Release
You can read more about what's in 4.0.0 in the 4.0.0-beta2 notes.
4.0.0-beta2 Release
This release includes the following features outlined here
TLDR;
- Generic type is now pass through the API from
Map<T>()
thanks to @slang25 ToStatusCode(..)
now has an overload which accepts theSystem.Net.HttpStatusCode
enum.
Ultimately these changes take the following example:
x.Map<HttpStatusCodeException>().ToStatusCode(ex => (int)((HttpStatusCodeException)ex).StatusCode);
and allow you to turn it into this:
x.Map<HttpStatusCodeException>().ToStatusCode(ex => ex.StatusCode);
Much better, right?!
4.0.0-beta1 Release
GlobalExceptionHandler 4.0.0-beta1 Changes
Changes for this release include:
API Changes
-
GlobalExceptionHandler no longer hangs off of
app.UseExceptionHandler()
and instead exists as a separate extension methodIApplicationBuilder
, egapp.UseGlobalExceptionHandler()
.The reason for this change was raised in this issue
-
The API names always felt a little verbose, so renamed some of them to what I feel is more concise. For instance:
Before:
app.UseGlobalExceptionHandler(x => {
x.ContentType = "application/json";
x.MessageFormatter(s => JsonConvert.SerializeObject(new
{
Message = "An error occured whilst processing your request"
}));
x.ForException<RecordNotFoundException>().ReturnStatusCode(StatusCodes.Status404NotFound).UsingMessageFormatter((e, c) => JsonConvert.SerializeObject(new {e.Message}));
});
After:
app.UseGlobalExceptionHandler(x => {
x.ContentType = "application/json";
x.ResponseBody(s => JsonConvert.SerializeObject(new
{
Message = "An error occured whilst processing your request"
}));
x.Map<RecordNotFoundException>().ToStatusCode(StatusCodes.Status404NotFound).WithBody((e, c) => JsonConvert.SerializeObject(new {e.Message}));
});
- You can now forward the status code from within an exception on (thanks to @shorbachuk for this suggestion in #20)
eg:
app.UseGlobalExceptionHandler(x =>
{
x.ContentType = "application/json";
x.Map<HttpServiceException>().ToStatusCode(ex => ex.StatusCode).WithBody((e, c) => "Something went wrong");
...
});