GlobalExceptionHandlerDotNet icon indicating copy to clipboard operation
GlobalExceptionHandlerDotNet copied to clipboard

any future plans for "problem+json"?

Open billkiddo opened this issue 7 years ago • 3 comments

billkiddo avatar Apr 25 '18 14:04 billkiddo

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

josephwoodward avatar May 08 '18 08:05 josephwoodward

@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
    });
});

josephwoodward avatar Sep 24 '18 21:09 josephwoodward

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” ?

shorbachuk avatar Oct 13 '18 17:10 shorbachuk