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

1

1 Answer 1

1

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

Sign up to request clarification or add additional context in comments.

3 Comments

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.
And you can catch each one before passing to all()
Yes, of course all of them may reject, but i meant that there will be only one error object of one rejected promise.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.