Created
September 2, 2015 08:44
-
-
Save dented/438dca338a8bcccad7bf to your computer and use it in GitHub Desktop.
Custom Error in JavaScript
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
| function MyError(code, msg) { | |
| this.message = msg; | |
| this.statusCode = code; | |
| this.name = 'HttpError'; | |
| const err = Error(msg); | |
| this.stack = err.stack; | |
| } | |
| MyError.prototype = Object.create(Error.prototype); | |
| MyError.prototype.constructor = MyError; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment