summaryrefslogtreecommitdiff
path: root/src/node/utils/customError.js
blob: 5ca7a7a41ed604679f814ca80e22943610cd1188 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
/*
 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.prototype = Error.prototype;

module.exports = customError;