pad.libre-service.eu-etherpad/src/node/utils/customError.js
Viljami Kuosmanen 3edd727a94 customError: rewrite the module using class syntax
The previous syntax caused a deprecation warning on Node 10.
However, due to the very old version of log4js Etherpad is currently using,
customError objects are going to be displayed as { inspect: [Function: inspect] }.

This needs to be addressed later, updating log4js.

Fixes #3834.
2020-04-07 02:03:17 +02:00

23 lines
534 B
JavaScript

/**
* 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);
}
}
module.exports = CustomError;