diff --git a/core/enig_error.js b/core/enig_error.js new file mode 100644 index 00000000..69722a85 --- /dev/null +++ b/core/enig_error.js @@ -0,0 +1,19 @@ +/* jslint node: true */ +'use strict'; + +class EnigError extends Error { + constructor(message) { + super(message); + + this.name = this.constructor.name; + this.message = message; + + if(typeof Error.captureStackTrace === 'function') { + Error.captureStackTrace(this, this.constructor); + } else { + this.stack = (new Error(message)).stack; + } + } +} + +exports.EnigError = EnigError; \ No newline at end of file