Created
June 9, 2017 11:11
-
-
Save akshendra/eddb8e665e41849a3f54d009bed82cf8 to your computer and use it in GitHub Desktop.
Extended error
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* @class QError | |
*/ | |
class QError extends Error { | |
/** | |
* @param {string} message | |
* @param {string} [type=error] | |
* @param {Object} [cause=null] - extra data for debugging | |
*/ | |
constructor(message, type = 'error', cause = null) { | |
super(message); | |
this.name = 'QError'; | |
this.type = type; | |
this.cause = cause; | |
if (typeof Error.captureStackTrace === 'function') { | |
Error.captureStackTrace(this, this.constructor); | |
} else { | |
this.stack = (new Error(message)).stack; | |
} | |
} | |
} | |
module.exports = QError; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment