Represents an HTTP-related error.

This error is thrown whenever an HTTP request encounters a non-successful HTTP status code. It includes detailed information about the request, including the status code, status text, URL, HTTP method, and response body.

The HttpError class masks lengthy non-JSON response bodies for readability in the error message.

Hierarchy

  • CustomError
    • HttpError

Properties

cause?: unknown
message: string
stack?: string
prepareStackTrace?: (err: Error, stackTraces: CallSite[]) => any

Optional override for formatting stack traces

stackTraceLimit: number

Accessors

  • get body(): string

    The response body of the request.

    Returns string

    If the response body was excessively long (and not JSON), it might be truncated in the error message for readability. Use this property to access the full response body if needed.

  • get name(): string

    Returns string

Methods

  • Create .stack property on a target object

    Parameters

    • targetObject: object
    • OptionalconstructorOpt: Function

    Returns void