Skip to content

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

Description

@janseris

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

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions