Skip to content

Instantly share code, notes, and snippets.

@AlexandroPerez
Created March 4, 2018 15:28
Show Gist options
  • Save AlexandroPerez/8cf1f5e35ef50d5a8f098bebd1caa31b to your computer and use it in GitHub Desktop.
Save AlexandroPerez/8cf1f5e35ef50d5a8f098bebd1caa31b to your computer and use it in GitHub Desktop.
myPromise.then(function() {
// Some error may happen
throw('An exception that would be caught');
}).catch(function() {
console.log('error');
});
// Is the same as this, the errHandle tries to catch any unhandled error
// from previous result.
myPromise.then(func, null).then(null, errHandle);
myPromise.then(function() {
// Some error may happen
throw('An unhandled exception.');
}, function() {
// This won't log the error if it happens in the
// some error may happen block.
console.log('error');
});
// Is the same as this, the errHandle will handle errors from previous result,
// but it won't handle errs in func.
myPromise.then(func, errHandle)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment