Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feature request] ProblemDetails middleware allow send Detail property out of the box in Production #194

Open
janseris opened this issue Apr 28, 2023 · 2 comments · May be fixed by #198
Open

Comments

@janseris
Copy link

janseris commented Apr 28, 2023

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

@janseris janseris changed the title ProblemDetails middleware allow send Detail property out of the box in Production [Feature request] ProblemDetails middleware allow send Detail property out of the box in Production Apr 28, 2023
@luizen
Copy link

luizen commented May 17, 2023

Please!

@PiotrKlimisz
Copy link

+1 🙏
It would be great to have a separate options for a stackframes and the details property.

jafin added a commit to jafin/Middleware that referenced this issue Aug 17, 2023
…tails) for response ProblemDetails response. Resolves khellang#194
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants