انتقل إلى المحتوى الرئيسي

Function: toProblem()

toProblem(error, correlationId?): ProblemDetails

Defined in: packages/common/src/problem.ts:361

Maps anything thrown to the problem to send.

  • A ProblemError passes through.
  • An error carrying a numeric HTTP status (Nest's HttpException exposes getStatus()) is mapped by class of status, with no detail: framework messages can echo input. 401, 403, 404 and 413 keep their kind; other 4xx become validation; 5xx become internal.
  • Everything else is internal.

Note 403 from a framework guard maps to forbidden; resource-scoped refusals must throw problems.notFound themselves, which only the service can know.

Parameters​

error​

unknown

correlationId?​

string

Returns​

ProblemDetails