Skip to main content
Version: Next

CustomErrorBase

Home > @backstage/errors > CustomErrorBase

A base class that custom Error classes can inherit from.

Signature:

class CustomErrorBase extends Error 

Extends: Error

Example

class MyCustomError extends CustomErrorBase {
name = 'MyCustomError' as const;
}

const e = new MyCustomError('Some message', cause);
// e.name === 'MyCustomError'
// e.message === 'Some message'
// e.cause === cause
// e.stack is set if the runtime supports it

Constructors

Constructor

Modifiers

Description

(constructor)(message, cause)

Constructs a new instance of the CustomErrorBase class

Properties

Property

Modifiers

Type

Description

cause?

readonly

Error | undefined

(Optional) An inner error that caused this error to be thrown, if any.