Last active
February 4, 2016 14:43
-
-
Save edysegura/3a682b9e6ff2e94b5b32 to your computer and use it in GitHub Desktop.
[JS] Customized exception in JavaScript
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
try { | |
anyFunction1(); | |
anyFunction2(); | |
anyFunction3(); | |
console.log('Success!'); | |
} | |
catch(e) { | |
console.log('Failed! Error: ' + e.message); | |
} | |
function anyFunction1() { | |
//throw {name:'MyError1', message:'my error message 1!'}; | |
} | |
function anyFunction2() { | |
//throw {name:'MyError2', message:'my error message 2!'}; | |
} | |
function anyFunction3() { | |
throw {name:'MyError3', message:'my error message 3!'}; | |
} | |
function anyFunction2() { | |
throw {name:'MyError2', message:'my message 2!'} | |
} | |
function anyFunction3() { | |
//throw {name:'MyError3', message:'my message 3!'} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment