2021-01-21 21:06:52 +00:00
|
|
|
'use strict';
|
2020-04-06 19:12:15 +02:00
|
|
|
/**
|
|
|
|
* CustomError
|
|
|
|
*
|
|
|
|
* This helper modules allows us to create different type of errors we can throw
|
|
|
|
*
|
|
|
|
* @class CustomError
|
|
|
|
* @extends {Error}
|
|
|
|
*/
|
|
|
|
class CustomError extends Error {
|
|
|
|
/**
|
|
|
|
* Creates an instance of CustomError.
|
|
|
|
* @param {*} message
|
|
|
|
* @param {string} [name='Error'] a custom name for the error object
|
|
|
|
* @memberof CustomError
|
|
|
|
*/
|
|
|
|
constructor(message, name = 'Error') {
|
|
|
|
super(message);
|
|
|
|
this.name = name;
|
|
|
|
Error.captureStackTrace(this, this.constructor);
|
|
|
|
}
|
2011-12-10 16:46:47 +01:00
|
|
|
}
|
|
|
|
|
2020-04-06 19:12:15 +02:00
|
|
|
module.exports = CustomError;
|