Created
April 30, 2016 19:30
-
-
Save auchomage/9e2bd15d71a166db332ee1e84bd231b7 to your computer and use it in GitHub Desktop.
try-catch example
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
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