Skip to content

Instantly share code, notes, and snippets.

@edysegura
Last active February 4, 2016 14:43
Show Gist options
  • Save edysegura/3a682b9e6ff2e94b5b32 to your computer and use it in GitHub Desktop.
Save edysegura/3a682b9e6ff2e94b5b32 to your computer and use it in GitHub Desktop.
[JS] Customized exception in JavaScript
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