Created
May 1, 2016 22:27
-
-
Save andrewjmead/0d64d848aa18cdaf9383448e6fe17a63 to your computer and use it in GitHub Desktop.
Jerome Try/Catch
This file contains hidden or 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
/** | |
* In the following example, the code in the try block will trigger the catch block | |
* without explicitly calling "throw new Error('error message')" | |
* | |
* When you try to reference a variable that does not exist, Node itself will throw | |
* the error. | |
*/ | |
try { | |
console.log(varNotReal); | |
} catch (e) { | |
console.log('Error', e); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Many thanks for this.
Things are clearer now.