The framework's HTTP error type.
-
details: Readonly<Record<string, unknown>>
Structured details appended to the error body. Omitted entirely when not supplied (never
undefined) so serialization stays clean. -
from(init: HttpErrorInit): HttpError
Creates an
HttpErrorfrom anHttpErrorInitobject. -
statusCode: number
The HTTP status code this error maps to.
Creates a 400 Bad Request error.
Creates a 409 Conflict error.
Framework-standard error formatter.
Creates a global error-handler middleware.
Creates a 403 Forbidden error.
Creates a 500 Internal Server Error error.
Creates a 404 Not Found error.
Creates a 501 Not Implemented error.
Format an error as RFC 9457 Problem Details.
Resolve the error format configuration to a concrete formatter function.
Resolves the human-readable title for a status code, falling back to a generic title for codes outside the well-known set.
Creates a 429 Too Many Requests error.
Creates a 422 Unprocessable Entity error wrapping a list of validation
failures.
Format an error as RFC 7807 Problem Details.
The framework-standard error body shape.
-
details: Readonly<Record<string, unknown>>
Optional structured details (present when the error carries any).
-
message: string
Human-readable error message.
-
stack: string
Optional stack trace (present only when
includeStackTraceis on). -
statusCode: number
The HTTP status code.
Options for the errorHandler middleware factory.
-
format: ErrorFormat | ErrorHandlerFormatter
The error body format:
'default','rfc9457', the deprecated'rfc7807', or a custom formatter function. Defaults to'default'. -
includeStackTrace: boolean
When
true, the errorstacktrace is included in the response body. Never enable this in production — pass a config-derived boolean (e.g.config.get('NODE_ENV') === 'development'), never readprocess.envdirectly (AI_GUIDELINES §4.1). Defaults tofalse. -
logErrors: boolean
When
true(the default), caught errors are logged aterrorlevel via theILoggerresolved fromctx.services— but only if a logger is registered. When no logger is present, logging is silently skipped. -
maskInternalErrors: boolean
When
true(the default), a caught value that was not anHttpErrorand resolves to a status>= 500is masked in the response: itsdetail/messagebecomes the status title ('Internal Server Error') and the raw message — which for a failed query carries the SQL and its bound parameter values — is dropped from the body. The log is unaffected:logErrorsstill records the unmasked error and its cause chain, so an operator loses nothing unlesslogErrorsis alsofalse, the configuration that already logs nothing. -
respond: () =>error: HttpError,ctx: IRequestContextHandlerResult
| undefined
| Promise<HandlerResult | undefined>Lets the application write its own response for a caught error. The hook receives the normalized error after status hints, internal-error masking, and status resolution, so
error.statusCodeis safe to serve. Return aHandlerResultproduced byctx.responseto use that response; it may resolve that result asynchronously. Return or resolve toundefinedto fall through to the configured formatter unchanged.
Options accepted by the HttpError constructor.
-
cause: Error
Optional underlying cause (forwarded to the ES2022
Errorcause chain). -
details: Readonly<Record<string, unknown>>
Optional structured details attached to the error body.
-
message: string
Human-readable error message.
-
statusCode: number
HTTP status code (e.g.
404).
A Problem Details object as defined by RFC 9457.
-
detail: string
A human-readable explanation specific to this occurrence.
-
errors: ReadonlyArray<{ field: string; message: string; code?: string; }>
Optional validation failures extension (present for
422errors). -
instance: string
A URI reference identifying the specific occurrence (request path).
-
stack: string
Optional stack trace (present only when
includeStackTraceis on). -
status: number
The HTTP status code generated for this occurrence.
-
title: string
A short, human-readable summary of the problem type.
-
type: string
A URI reference identifying the problem type.
A single validation failure carried by a 422 error.
-
code: string
Optional machine-readable failure code.
-
field: string
Dot-path of the offending field (e.g.
"address.zip"). -
message: string
Human-readable description of the failure.
The built-in error format identifiers for @setu-ts/exceptions.
A function that formats a thrown error into a serializable error body.
The canonical base URI for framework-produced problem type identifiers.
A human-readable title for a given HTTP status code. This is the single
source of truth used by both the factory functions and the Problem Details
formatters so the title field never drifts from the produced statusCode.
Usage
import * as Exception_factory_functions___HttpError___error_formatters__and_the_global_error_handler_middleware___This_is_a___plain_package____not_a_plugin____it_depends_on___setu_ts_common__only_and_exposes_types__factories__and_a_middleware_factory__Register_the_middleware_via_the_application_s_pipeline______typescript_import___errorHandler___from___setu_ts_exceptions____app_middleware_add_errorHandler___format___rfc9457________priority__0__name___error_handler____________Every_export_here_is_public_API_and_documented_in_PUBLIC_API_md__AI_GUIDELINES__10__ from "exceptions/src/index.ts";