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):
The current middleware implementation allows to send in ProblemDetails: a) only
Title
(default option for Production)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 DevelopmentSometimes it is convenient for a client to know at least a bit of what happened, thus send
Detail
in theProblemDetail
in Production.Suggested new option: c)
Title
andDetail
for Production environmentTitle
- automatically as status code name (same as now)Detail
- original exception messagePublic 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:
Reference implementation which already contains this behavior: https://stackoverflow.com/a/74487747