Created
December 11, 2017 12:52
-
-
Save ralphtheninja/a62c0bcee51fef0bccf1a3eb3c0c703d to your computer and use it in GitHub Desktop.
node-errno
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
const create = require('.').create | |
const CustomError = require('.').custom.CustomError | |
const inherits = require('inherits') | |
// inherits from CustomError (which inherits from Error) | |
const MyError = create('MyError') | |
const MyError3 = create('MyError3', MyError) | |
// same but using traditional inheritance | |
function MyError2 (message, cause) { | |
CustomError.call(this, message, cause) | |
} | |
inherits(MyError2, CustomError) | |
function bar () { | |
console.log(new MyError().stack) | |
console.log(new MyError2('MyError2', 'woot').stack) | |
console.log(new MyError3('MyError3', 'woot').stack) | |
} | |
function foo () { | |
bar() | |
} | |
foo() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment