Skip to content

Instantly share code, notes, and snippets.

@meaku
Created November 19, 2015 19:29
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 meaku/89623ea3ea3826210d8e to your computer and use it in GitHub Desktop.
Save meaku/89623ea3ea3826210d8e to your computer and use it in GitHub Desktop.
function failing() {
return new Promise((resolve, reject) => {
setTimeout(function() {
reject(new Error("failed"));
},10);
});
}
function succeeding() {
return new Promise((resolve, reject) => {
setTimeout(function() {
resolve(123);
}, 10);
});
}
router.get("/bla",
function *(next) {
console.log("1");
try {
this.state.bla = yield failing();
yield next;
console.log("1 after");
}
catch(err) {
console.log("catch");
this.throw(err);
}
},
function *(next) {
console.log("2");
this.state.blub = yield succeeding();
yield next;
console.log("2 after");
},
function *() {
this.body = {a: "b"};
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment