Skip to content

Instantly share code, notes, and snippets.

@dg3feiko
Created April 27, 2016 03:00
Show Gist options
  • Save dg3feiko/c83913ed7eec2045f16360aef6f8179b to your computer and use it in GitHub Desktop.
Save dg3feiko/c83913ed7eec2045f16360aef6f8179b to your computer and use it in GitHub Desktop.
'use strict';
const co = require("./co.js");
const co_nothrow = require("./co-nothrow");
var boom = ()=> {
return new Promise((resolve, reject)=>{
setTimeout(()=>{
reject("boom");
}, 1000);
})
};
co(function *() {
try {
yield boom();
console.log("[co] done");
} catch (e) {
console.error("[co] error:", e);
}
});
co_nothrow(function *() {
let [err, res] = yield boom();
console.log("[co no-throw] done:", err, res);
});
@dg3feiko
Copy link
Author

console output

[co] error: boom
[co no-throw] done: boom null

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment