Created
June 30, 2014 15:01
-
-
Save codyhanson/77835fb033667d5d4ed9 to your computer and use it in GitHub Desktop.
Javascript Exception Handling
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
#!/usr/bin/env node | |
function asyncCall(callback){ | |
console.log('Starting Async Function'); | |
setTimeout(callback,1000); | |
} | |
try { | |
asyncCall(function (){ | |
var err = new Error('MyError'); | |
err.message = 'Async Error'; | |
throw err; | |
}); | |
var err = new Error('MyError'); | |
err.message = 'non-Async Error'; | |
throw err; | |
} catch(error) { | |
console.log('Caught:' + error.message); | |
} | |
console.log('Done with Try Catch block'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment