@webbio/viper-core-utils
Version:
Webbio's error interface which is used in the Viper Project
47 lines • 1.21 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
/**
* Every specific custom error will extend this class
* This class defines the basics that every error can do
*/
class BaseError {
/**
* Creating a new BaseError instance
* @param name Name of the error
* @param message Optional descriptive message about why this error is thrown
* @param stack Optional stack of the error
*/
constructor(logger, name, message, stack) {
this.logger = logger;
this.name = name;
this.message = message;
this.stack = stack;
}
/**
* Retrieve the name of the error
*/
getName() {
return this.name;
}
/**
* Retrieve the optional descriptive name of the error
*/
getMessage() {
return this.message;
}
/**
* Retrieve the optional stack of the error
*/
getStack() {
return this.stack;
}
/**
* Report the error using some sort of logger
* @param logger A logger service that handles some sort of logging
*/
report() {
this.logger.log(this);
}
}
exports.default = BaseError;
//# sourceMappingURL=baseError.js.map