Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 21 additions & 15 deletions src/node/utils/customError.js
Original file line number Diff line number Diff line change
@@ -1,17 +1,23 @@
/*
This helper modules allows us to create different type of errors we can throw
*/
function customError(message, errorName)
{
this.name = errorName || "Error";
this.message = message;

var stackParts = new Error().stack.split("\n");
stackParts.splice(0,2);
stackParts.unshift(this.name + ": " + message);

this.stack = stackParts.join("\n");
/**
* 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);
}
}
customError.prototype = Error.prototype;

module.exports = customError;
module.exports = CustomError;
Comment thread
muxator marked this conversation as resolved.