Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- myPromise.then(function() {
- console.log('success');
- }).catch(function() {
- console.log('error');
- });
- myPromise.then(function() {
- console.log('success');
- }, function() {
- console.log('error');
- });
- 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)
Add Comment
Please, Sign In to add comment