1

How can I handle errors from other than first promise rejection?

Example:

Promise.all[p1, p2, p3].then(...)
.catch((error) => { console.log(error) })

Order of rejection: p1 p2 p3

Is it possible to get errors from p2 and p3?

EDIT: from comments below: is it possible to catch error from specific Promise before passing it to .all? E.g. I want to stay with Promise.all funcionality but log all error cases also

  • See also https://stackoverflow.com/questions/31424561/wait-until-all-es6-promises-complete-even-rejected-promises – Estus Flask Jul 04 '17 at 21:15

1 Answers1

1

There will be only one rejected promise. No more. You'll receive error for the first one rejected and that's it.

Angels
  • 230
  • 1
  • 8
  • 3
    This isn't true. Any or all of the promises may reject, but regardless of how many reject, only the first one's error is mad available to `catch`. – user229044 Jul 04 '17 at 21:11
  • And you can catch each one before passing to all() – charlietfl Jul 04 '17 at 21:13
  • Yes, of course all of them may reject, but i meant that there will be only one error object of one rejected promise. – Angels Jul 04 '17 at 21:16