Guest User

Untitled

a guest
Dec 18th, 2017
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.88 KB | None | 0 0
  1. myPromise.then(function() {
  2. console.log('success');
  3. }).catch(function() {
  4. console.log('error');
  5. });
  6.  
  7. myPromise.then(function() {
  8. console.log('success');
  9. }, function() {
  10. console.log('error');
  11. });
  12.  
  13. myPromise.then(function() {
  14. // Some error may happen
  15. throw('An exception that would be caught');
  16. }).catch(function() {
  17. console.log('error');
  18. });
  19. // Is the same as this, the errHandle tries to catch any unhandled error
  20. // from previous result.
  21. myPromise.then(func, null).then(null, errHandle);
  22.  
  23.  
  24. myPromise.then(function() {
  25. // Some error may happen
  26. throw('An unhandled exception.');
  27. }, function() {
  28. // This won't log the error if it happens in the
  29. // some error may happen block.
  30. console.log('error');
  31. });
  32. // Is the same as this, the errHandle will handle errors from previous result,
  33. // but it won't handle errs in func.
  34. myPromise.then(func, errHandle)
Add Comment
Please, Sign In to add comment