Created
April 27, 2016 03:00
-
-
Save dg3feiko/c83913ed7eec2045f16360aef6f8179b to your computer and use it in GitHub Desktop.
This file contains 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
'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); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
console output