josephwoodward / GlobalExceptionHandlerDotNet

Exception handling as a convention in the ASP.NET Core request pipeline
MIT License
272 stars 32 forks source link

any future plans for "problem+json"? #17

Open billkiddo opened 6 years ago

josephwoodward commented 6 years ago

Yes, definitely. I've been looking at a couple of options around implementation.

josephwoodward commented 6 years ago

@billkiddo Currently working on adding Problem+json support now, interested in your thoughts and opinions around the implementation. This is what I currently have:

app.UseGlobalExceptionHandler(x =>
{
    x.Map<ArgumentException>().ToStatusCode(HttpStatusCode.BadRequest).UsingProblemDetails((ex, context) => new ProblemDetails
    {
        Type = ex.GetType().Name,
        Detail = ex.Message,
        Title = "There was an error with your request",
        Instance = "My instance",
        Status = context.StatusCode
    });
});
shorbachuk commented 5 years ago

That implementation looks good to me. I thought ProblemDetails was part of 2.1...

Does this simply automatically set the content type?

What is supposed to be used for “Instance” ?