Advertisement
Guest User

Untitled

a guest
Jul 3rd, 2015
195
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.76 KB | None | 0 0
  1. Promise.resolve(process.hrtime())
  2. .then(returnAPromise)
  3. .then(returnAValue)
  4. .then(returnAPromise)
  5. .then(throwAnException)
  6. .catch(handleExceptionAndReturnPromise)
  7. .then(returnAPromise)
  8. .then(throwAnException)
  9. .catch(handleFinalException)
  10.  
  11. function returnAPromise(value) {
  12. console.log(value);
  13.  
  14. return Promise.resolve(process.hrtime());
  15. }
  16.  
  17. function returnAValue(value) {
  18. console.log(value);
  19. return process.hrtime();
  20. }
  21.  
  22. function handleFinalException(error) {
  23. console.log("all done", error);
  24. }
  25.  
  26. function throwAnException(value) {
  27. console.log(value, "about to throw!");
  28. throw "exception thrown!";
  29. }
  30.  
  31. function handleExceptionAndReturnPromise(error) {
  32. console.log(error);
  33.  
  34. return Promise.resolve(process.hrtime());
  35. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement