Skip to content

Instantly share code, notes, and snippets.

@alacambra
Created April 22, 2017 19:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save alacambra/07fae6718bd0221e6c65704a739987a0 to your computer and use it in GitHub Desktop.
Save alacambra/07fae6718bd0221e6c65704a739987a0 to your computer and use it in GitHub Desktop.
new Promise(function (resolve, reject) {
resolve("my data");
reject("my error");
})
.then((data) => ho(data, 1)
// , err => {
// he(err, 1);
// return Promise.reject(err)
// }
)
.then((data) => ho(data, 2)
// , err => he(err, 2)
)
.then((data) => ho(data, 3)
// , err => he(err, 3)
, err => Promise.reject(err + " on 3")
)
.then((data) => ho(data, 4)
// , err => he(err, 4)
)
.catch(thr => console.info("catched....", thr))
;
function he(err, i) {
console.info("handle error: " + i, err);
return err + i;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment