function selectFormatter
Since 0.1.0
selectFormatter(format?: ErrorFormat | ErrorHandlerFormatter): ErrorHandlerFormatter

Resolve the error format configuration to a concrete formatter function.

  • When format is 'default', 'rfc9457', or the deprecated 'rfc7807', the corresponding built-in formatter is returned.
  • When format is already a function, it is returned as-is.
  • Otherwise a TypeError is thrown.

Parameters

optional
format: ErrorFormat | ErrorHandlerFormatter = default

The error format identifier or custom formatter function

Return Type

The resolved formatter function

Throws

TypeError

When an unknown format string is provided

Usage

import { selectFormatter } from "exceptions/src/index.ts";