@elsikora/cladi
Version:
ClaDI is a library for creating and managing classes in TypeScript.
30 lines (28 loc) • 790 B
JavaScript
/**
* 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);
}
}
}
export { BaseError };
//# sourceMappingURL=error.class.js.map