Skip to main content

Class: GeneralError

Class to handle general-purpose errors.

Extends​

Constructors​

Constructor​

new GeneralError(source, message, properties?, cause?): GeneralError

Create a new instance of GeneralError.

Parameters​

source​

string

The source of the error.

message​

string

The message as an i18n key.

properties?​

Any additional information for the error.

cause?​

unknown

The cause of the error if we have wrapped another error.

Returns​

GeneralError

Overrides​

BaseError.constructor

Properties​

source?​

optional source?: string

The source of the error.

Inherited from​

BaseError.source


properties?​

optional properties?: object

Any additional information for the error.

Index Signature​

[id: string]: unknown

Inherited from​

BaseError.properties


cause?​

optional cause?: IError

The cause of the error.

Inherited from​

BaseError.cause


CLASS_NAME​

readonly static CLASS_NAME: string

Runtime name for the class.

Methods​

fromError()​

static fromError(err): BaseError

Construct an error from an existing one.

Parameters​

err​

unknown

The existing error.

Returns​

BaseError

The new instance.

Inherited from​

BaseError.fromError


flatten()​

static flatten(err): IError[]

Flatten an error tree.

Parameters​

err​

unknown

The starting error.

Returns​

IError[]

The list of all internal errors.

Inherited from​

BaseError.flatten


expand()​

static expand(errors): IError | undefined

Expand an error tree.

Parameters​

errors​

IError[] | undefined

The list of errors to expand.

Returns​

IError | undefined

The first level error.

Inherited from​

BaseError.expand


isErrorName()​

static isErrorName(error, name): error is BaseError

Test to see if the error has the specified error name.

Parameters​

error​

unknown

The error to test.

name​

string | RegExp

The name to check for.

Returns​

error is BaseError

True if the error has the name.

Inherited from​

BaseError.isErrorName


isErrorMessage()​

static isErrorMessage(error, message): error is BaseError

Test to see if the error has the specified error message.

Parameters​

error​

unknown

The error to test.

message​

string | RegExp

The message to check for.

Returns​

error is BaseError

True if the error has the name.

Inherited from​

BaseError.isErrorMessage


isErrorCode()​

static isErrorCode(error, code): boolean

Test to see if the error has the specified error code.

Parameters​

error​

unknown

The error to test.

code​

string | RegExp

The code to check for.

Returns​

boolean

True if the error has the code.

Inherited from​

BaseError.isErrorCode


someErrorName()​

static someErrorName(error, name): error is BaseError

Test to see if any of the errors or children have the given error name.

Parameters​

error​

unknown

The error to test.

name​

string | RegExp

The name to check for.

Returns​

error is BaseError

True if the error has the name.

Inherited from​

BaseError.someErrorName


someErrorMessage()​

static someErrorMessage(error, message): error is BaseError

Test to see if any of the errors or children have the given error message.

Parameters​

error​

unknown

The error to test.

message​

string | RegExp

The message to check for.

Returns​

error is BaseError

True if the error has the name.

Inherited from​

BaseError.someErrorMessage


someErrorClass()​

static someErrorClass(error, cls): error is BaseError

Test to see if any of the errors or children are from a specific class.

Parameters​

error​

unknown

The error to test.

cls​

string

The class to check for.

Returns​

error is BaseError

True if the error has the specific class.

Inherited from​

BaseError.someErrorClass


someErrorCode()​

static someErrorCode(error, code): error is BaseError

Test to see if any of the errors or children have the given error code.

Parameters​

error​

unknown

The error to test.

code​

string | RegExp

The code to check for.

Returns​

error is BaseError

True if the error has the name.

Inherited from​

BaseError.someErrorCode


isEmpty()​

static isEmpty(err): boolean

Is the error empty, i.e. does it have no message, source, properties, or cause?

Parameters​

err​

IError

The error to check for being empty.

Returns​

boolean

True if the error is empty.

Inherited from​

BaseError.isEmpty


isAggregateError()​

static isAggregateError(err): err is AggregateError

Is the error an aggregate error.

Parameters​

err​

unknown

The error to check for being an aggregate error.

Returns​

err is AggregateError

True if the error is an aggregate error.

Inherited from​

BaseError.isAggregateError


fromAggregate()​

static fromAggregate(err, includeStackTrace?): IError[]

Convert the aggregate error to an array of errors.

Parameters​

err​

unknown

The error to convert.

includeStackTrace?​

boolean

Whether to include the error stack in the model, defaults to false.

Returns​

IError[]

The array of errors.

Inherited from​

BaseError.fromAggregate


toJsonObject()​

toJsonObject(includeStackTrace?): IError

Serialize the error to the error model.

Parameters​

includeStackTrace?​

boolean

Whether to include the error stack in the model, defaults to false.

Returns​

IError

The error model.

Inherited from​

BaseError.toJsonObject