Handling errors with Promise.catch

In a previous recipe, we saw how to fulfill a promise with an error state using reject, and we saw that this triggers the next catch callback in the promise chain. Because promises are relatively easy to compose, we need to be able to handle errors that are reported in different ways. Luckily promises are able to handle this seamlessly.

In this recipe, we'll see how Promises.catch can handle errors that are reported by being thrown or through rejection.