Extended API error that encompasses both OpenAPI errors and other API-related errors

Hierarchy (View Summary)

Constructors

  • Constructor for the APIError class

    Parameters

    • statusCode: number

      The HTTP status code

    • errorType: APIErrorType

      The type of error

    • errorMessage: string

      The error message

    • OptionalcorrelationId: string

      The correlation ID

    • OptionalerrorLink: string

      URL to documentation about this error

    • Optionalcause: Error

      The cause of the error

    Returns APIError

Properties

cause?: unknown
correlationId?: string
errorLink?: string
errorMessage: string
errorType: APIErrorType
message: string
name: string
stack?: string
statusCode: number
prepareStackTrace?: (err: Error, stackTraces: CallSite[]) => any

Optional override for formatting stack traces

stackTraceLimit: number

Methods

  • Convert the error to a JSON object, excluding undefined properties

    Returns {
        correlationId?: string;
        errorLink?: string;
        errorMessage: string;
        errorType: APIErrorType;
        name: string;
        statusCode: number;
    }

    The error as a JSON object

  • Create .stack property on a target object

    Parameters

    • targetObject: object
    • OptionalconstructorOpt: Function

    Returns void