Now when it comes to error handling, there are a few quirks; so, we'll simulate some errors. First up, let's simulate an error in our second asyncAdd call. We know we can do that by passing in a value that's not a number. In this case, let's wrap 33 inside quotes:
asyncAdd(5, 7).then((res) => {
console.log('Result:', res);
return asyncAdd(res, '33');
}, (errorMessage) => {
console.log(errorMessage);
}).then((res) => {
console.log('Should be 45', res);
}, (errorMessage) => {
concole.log(errorMessage);
})
This will be a string and our call should reject. Now we can save the file and see what happens:

We get Result: 12, then we get our error, Arguments must be numbers. Exactly as we expect, this is printing on the screen. Instead of getting Should be 45, we get our error message.
But things get a little trickier when something earlier on in the promise chain gets rejected. Let's swap '33' with the number 33. Then let's replace 7 with the string '7', as shown here:
asyncAdd(5, '7').then((res) => {
console.log('Result:', res);
return asyncAdd(res, 33);
}, (errorMessage) => {
console.log(errorMessage);
}).then((res) => {
console.log('Should be 45', res);
}, (errorMessage) => {
concole.log(errorMessage);
})
This will cause our first promise to fail, which means we'll never see the result. We should see the error message printing to the screen, but that's not what will happen:

When we restart, we do indeed get the error message printing to the screen, but then we also get Should be 45 undefined. The second then console.log is running because we provided an error handler in the second asyncAdd function. It's running the error handler. Then it says, Okay, things must be good now we ran the error handler. Let's move on to the next then call calling the success case.