/*
* A single promise can pass through several chained
* `then` statements because `then` returns a promise
* as well
*/
new Promise((resolve, reject) => {
console.log("new Promise A")
reject("error statement")
// same as throw new Error("error statement")
resolve(2) // wont run
}).then((data) => {
// wont run
console.log(`A ${data}`);
return data * 2
}).then((data) => {
// wont run
console.log(`B ${data}`);
return data * 2
}).catch((error) => {
console.warn(`ERROR A: ${error}`)
}).catch((error) => {
// would only run if the previous catch threw an error
console.warn(`ERROR B: ${error}`)
})