Created
August 5, 2022 13:15
-
-
Save ziedHamdi/09d7556b3cc06e07e47a71321d5046a5 to your computer and use it in GitHub Desktop.
This file contains 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 ExtendableError extends Error { | |
constructor(message, errorCode) { | |
super(JSON.stringify( {text:message, code:errorCode} )) | |
this.name = this.constructor.name; | |
// this.errorCode = errorCode | |
if (typeof Error.captureStackTrace === 'function') { | |
Error.captureStackTrace(this, this.constructor); | |
} else { | |
this.stack = (new Error(message)).stack; | |
} | |
} | |
} | |
export default ExtendableError |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment