Custom error class for handling HTTP request errors.

The error message.

The HTTP status code associated with the error.

Additional data related to the error.

try {
// Some code that may throw an error
} catch (error) {
throw new CustomError('Failed to fetch resource', 500, error);
}

Hierarchy

  • Error
    • CustomError

Constructors

Properties

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

Optional override for formatting stack traces

stackTraceLimit: number

Methods

  • Create .stack property on a target object

    Parameters

    • targetObject: object
    • OptionalconstructorOpt: Function

    Returns void