UNPKG

@elsikora/cladi

Version:

ClaDI is a library for creating and managing classes in TypeScript.

32 lines (29 loc) 814 B
'use strict'; /** * Base error class. * @see {@link https://elsikora.com/docs/cladi/core-concepts/error-handling} */ class BaseError extends Error { CAUSE; CODE; CONTEXT; SOURCE; /** * Creates a new base error. * @param {string} message Error message. * @param {IBaseErrorOptions} options Error options. */ constructor(message, options) { super(message); this.name = this.constructor.name; this.CAUSE = options.cause; this.CODE = options.code; this.CONTEXT = options.context; this.SOURCE = options.source; if (typeof Error.captureStackTrace === "function") { Error.captureStackTrace(this, this.constructor); } } } exports.BaseError = BaseError; //# sourceMappingURL=error.class.js.map