Handling errors thrown inside of Promise.all

In a prior recipe, we saw how to use Promise.all to collect the results of multiple asynchronous functions. In an error state, Promise.all is even more interesting. Often, when dealing with multiple possible error conditions, we have to write a log of Boolean logic if we want to display multiple error messages. But, in this recipe, we'll see how we can use Promise.all and try-catch blocks to handle multiple error conditions concurrently, without complicated Boolean logic.

Get ECMAScript Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.