Skip to content

Releases: josephwoodward/GlobalExceptionHandlerDotNet

Test title

13 Feb 03:45
Compare
Choose a tag to compare
4.0.3

Clean up

4.0.2 Release

15 Mar 09:35
Compare
Choose a tag to compare

#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

19 Feb 09:24
b02ea0c
Compare
Choose a tag to compare

Fix for #28

4.0.0 Release

27 Oct 06:51
Compare
Choose a tag to compare

You can read more about what's in 4.0.0 in the 4.0.0-beta2 notes.

4.0.0-beta2 Release

20 Sep 00:26
656f187
Compare
Choose a tag to compare

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 the System.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?!

Alt Text

4.0.0-beta1 Release

18 Sep 22:35
Compare
Choose a tag to compare

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 method IApplicationBuilder, eg app.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");
    ...
});

Version 3.0.0

20 Dec 14:40
Compare
Choose a tag to compare

Changes include:

#13 Fixed by @slang25