Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
nodesec-error-handling
//snippet1 : Following is not a proper error handling when myAsyncFunction() is an asynchronous function
try {
myAsyncFunction(somedata, function(err, response){
//this is asynchronous function callback
});
}
catch(err){
console.log('I will never catch the error');
}
//snippet2 : Following is a proper error handling when mySyncFunction() is synchronous
try {
var val = mySyncFunction(somedata);
/* do something with val */
}
catch(err){
console.log('Yes. I caught the error');
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.