How it works...

As in the preceding recipe, the errors are caught by the main function, and the launch continue or abort message is displayed. In this recipe, we've grouped the check function into a single asynchronous function, performChecks, that lets us know when they have all finished.

Because performChecks does not have a catch block on the awaited Promise result, the errors thrown lower in the call stack bubble up to the main function. However, the finally block ensures that there is a message to let us know that the performChecks has completed.

You can imagine that this organization could be expanded to include multiple layers, and other branches of operations. Handling errors is an important task in large programs, and async/await ...

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.