-
Notifications
You must be signed in to change notification settings - Fork 108
Open
Description
The current middleware implementation allows to send in ProblemDetails:
a) only Title
(default option for Production)
- title is constructed automatically from the status code name
Detail
property is not filled
b)Title
,Details
and a lot of exception details and method context and lines of source code etc. (default option for Development
- details is taken from the original exception message
Sometimes it is convenient for a client to know at least a bit of what happened, thus send Detail
in the ProblemDetail
in Production.
Suggested new option:
c) Title
and Detail
for Production environment
Title
- automatically as status code name (same as now)Detail
- original exception message
Public API changes (new), no modification of the original public API is required (no breaking change):
ProblemDetailsOptions.MapToStatusCodeWithDetail<TException>(int statusCode)
as an alternative for the current API:
ProblemDetailsOptions.MapToStatusCode<TException>(int statusCode)
Example:
options.MapToStatusCodeWithDetail<ValidationException>(StatusCodes.Status422UnprocessableEntity);
Reference implementation which already contains this behavior:
https://stackoverflow.com/a/74487747
luizen, peabit, neilhsmith and litenova
Metadata
Metadata
Assignees
Labels
No labels