You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I've been playing around with the built in ProblemDetailserror handling and confused about the reasoning for this:
Minimal API apps can be configured to generate problem details response for all HTTP client and server error responses that don't have body content yet by using the AddProblemDetails extension method.
(emphasis both mine and also in the official docs)
Why can't we have (by default) a 4XX status code ... which happens to have a custom error message, end up being a problem details?
for example:
app.UseStatusCodePages();
...
app.MapGet("/statuscode/{statuscode:int}", (int statuscode) => Results.StatusCode(statuscode); // Renders a PD for the status code. Assume statuscode is a valid number.
app.MapGet("/statuscode/badrequest", => Results.BadRequest("hi there"); // Returns a single line.
so with the statuscode/badrequest the response payload is:
application/json; charset=utf-8
Hi there
but I would have thought that we could make that a problem details with the details key having the value set to be the message that would have been passed to the Bad Request object.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
I've been playing around with the built in
ProblemDetails
error handling and confused about the reasoning for this:(emphasis both mine and also in the official docs)
Why can't we have (by default) a 4XX status code ... which happens to have a custom error message, end up being a problem details?
for example:
so with the
statuscode/badrequest
the response payload is:application/json; charset=utf-8
Hi there
but I would have thought that we could make that a problem details with the
details
key having the value set to be the message that would have been passed to the Bad Request object.RFC 7807 - Problem Details has provision for a
details
key/value.Is this a possibility to be added? If yes, i can make an issue.
If not / there's a reason why it's not .. can anyone explain why?
I know not every response object has the ability to display an error message.
Beta Was this translation helpful? Give feedback.
All reactions