Basalt error class that extends the (Error) class and provides additional properties. (uuidError, date, code, fileName, line, column)

T - The type of the cause of the error.

The following example demonstrates how to throw a new instance of the Basalt error.

try {
throw new BasaltError();
} catch (error) {
console.log(error instanceof BasaltError); // true
console.log(error instanceof Error); // true
// u can access to uuidError, date, code, fileName, line, column, message, name, stack, cause
}

The following example demonstrates how to create a new instance of the Basalt error with provided type for the cause.

const basaltError: BasaltError<{ foo: 'bar' }> = new BasaltError({
key: 'error.unknown',
cause: {
foo: 'bar',
},
});
console.log(basaltError.cause); // { foo: 'bar' } if you make ctrl + space after cause. you will see the properties of the cause

Type Parameters

  • T = unknown

Hierarchy

  • Error
    • BasaltError

Constructors

Properties

cause: undefined | T
message: string
name: string
stack?: string
prepareStackTrace?: (err: Error, stackTraces: CallSite[]) => any

Optional override for formatting stack traces

stackTraceLimit: number

Accessors

Methods

  • Create .stack property on a target object

    Parameters

    • targetObject: object
    • OptionalconstructorOpt: Function

    Returns void

  • Create .stack property on a target object

    Parameters

    • targetObject: object
    • OptionalconstructorOpt: Function

    Returns void