Class APIError

Class representing an API error.

Hierarchy

  • Error
    • APIError

Constructors

  • Creates an instance of APIError.

    Parameters

    • code: number

      The error code.

    • message: string

      The error message.

    • response: undefined | AxiosResponse<any, any>

      The Axios response associated with the error.

    Returns APIError

    const error = new APIError(404, 'Not Found', response);
    

Properties

code: number

The error code.

message: string

The error message.

name: string
response: undefined | AxiosResponse<any, any>

The Axios response associated with the error.

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

Optional override for formatting stack traces

stackTraceLimit: number

Methods

  • Returns a string representation of the APIError.

    Returns string

    A string describing the error.

    const error = new APIError(404, 'Not Found', response);
    console.log(error.toString()); // "APIError(code=404): Not Found"
  • Create .stack property on a target object

    Parameters

    • targetObject: object
    • OptionalconstructorOpt: Function

    Returns void