Class HTTPError

A type of error to be used on HTTP requests. This is the most common type of error used by Jimpex.

Hierarchy (view full)

Constructors

  • Parameters

    • message: string

      The error message.

    • status: string | number = ...

      The HTTP status code.

    • context: AppErrorContext = {}

      Context information related to the error.

    • 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 HTTPError

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