Following is an example:
var promise = new Promise(function(resolve, reject) {
throw new Error('test');
});
promise.catch(function(error) {
console.log(error + ' 1 ');
return error
}).catch(function(error) {
console.log(error + ' 2 ');
return error
})
The result for the codes are:
Error: test 1
As can be seen, the second catch
call doesn't work. Does that mean Promise cannot handle error using the chain syntax of catch
? Is there a way to pass the current error to the next catch()
call?