Class AppError

A simple subclass of Error but with support for context information.

Hierarchy (view full)

Constructors

  • Parameters

    • message: string

      The message of the error.

    • context: AppErrorContext = {}

      The context information, for the error handler.

    • statuses: Statuses = statusesFn

      A reference to the service that generates HTTP status codes. This is in case the implementation wants to use a special version from the container; otherwise, it will use the statuses library directly.

    Returns AppError

Properties

_context: AppErrorContext

The context information that can be provided to the error, and picked by the error handler.

_date: Date

The date of when the error was generated.

_statuses: Statuses

The service that generates HTTP status codes.

Accessors

  • get response(): unknown
  • Information about the error that can be included in a response. This is set using the response key in the context option.

    Returns unknown

  • get status(): undefined | number
  • An HTTP status code related to the error. This is set using the status key on the context.

    Returns undefined | number

Methods

  • Gets an object that can be included in a response from the application. This method is a helper for the response getter, as it allows for the assertion of the response type.

    Type Parameters

    • T

      The type of the response.

    Returns T

Generated using TypeDoc