Custom error object that extends the default Error but has a more versatile constructor that allows setting additional standard error fields such as name while also allowing setting of custom fields through the constructor making it easier to include extra detail into the error

Hierarchy

  • Error
    • CustomError

Constructors

Properties

cause?: unknown
code?: string

Optional code of the error

message: string
name: string
stack?: string
prepareStackTrace?: ((err, stackTraces) => any)

Type declaration

stackTraceLimit: number

Methods

  • Create .stack property on a target object

    Parameters

    • targetObject: object
    • Optional constructorOpt: Function

    Returns void