biz2credit-code-challenge-gaurav-pandey-2
Version:
Code Challenge for Gaurav Pandey
23 lines (22 loc) • 688 B
JavaScript
/**
* @class : AppError
* @author : Gaurav Pandey
* @created : 2020-02-24
* @extends : Error class provided natively by Node.js
* @description : Created as an extention to the default Error class in node.js.
* To distinguish between handled exceptions vs unhandled exceptions.
* All the errors thrown explicitly in whole application would be of this specific class.
*
*/
class AppError extends Error {
constructor(error) {
super(error);
this.name = this.constructor.name;
if (typeof Error.captureStackTrace === 'function') {
Error.captureStackTrace(this, this.constructor);
} else {
this.stack = (new Error(error)).stack;
}
}
}
module.exports = AppError;