Skip to main content

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

ConstructorModifiersDescription
(constructor)(message, cause)Constructs a new instance of the CustomErrorBase class

Properties

PropertyModifiersTypeDescription
cause?readonlyError | undefined(Optional) An inner error that caused this error to be thrown, if any.