In the following code the Promise.reject
doesn't work unless I specifically use return Promise.reject(...)
. Why is this?
Promise.resolve('Promise 1 Done')
.then(function(result) {
console.log(result);
return 'Promise 2 Done'
}).then(function(result) {
let j;
try {
j = JSON.parse("invalid will throw");
console.log(j);
} catch(err) {
Promise.reject('Could not parse JSON');
}
console.log(result);
}).catch(function(err) {
console.log(err);
});