Skip to content

Instantly share code, notes, and snippets.

@auchomage
Created April 30, 2016 19:30
Show Gist options
  • Save auchomage/9e2bd15d71a166db332ee1e84bd231b7 to your computer and use it in GitHub Desktop.
Save auchomage/9e2bd15d71a166db332ee1e84bd231b7 to your computer and use it in GitHub Desktop.
try-catch example
function doWork(){
// throw an error that says unable to work
console.log("Unable to work!");
}
try {
// call doWork()
throw new Error(doWork());
} catch (e) {
console.log(e.message);
} finally {
console.log('Finally block executed!');
}
console.log('try-catch2, ended.');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment