class MyError extends Error {} | |
try { | |
doStuff(); | |
} catch(err) { | |
if (err.name == 'MyError') { | |
console.log("This is my error"); | |
} else if (err.name == 'ReferenceError') { | |
console.log("Not my error. Ask the ReferenceError guys"); | |
} else { | |
console.log("I have no idea"); | |
throw err; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment