Created
November 19, 2015 19:29
-
-
Save meaku/89623ea3ea3826210d8e to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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