Created
January 25, 2014 04:49
-
-
Save geekingfrog/8612025 to your computer and use it in GitHub Desktop.
Yield and uncaught exception in coroutine
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
var Promise = require('bluebird'); | |
// log the error | |
Promise.onPossiblyUnhandledRejection(function(error){ | |
// this will be called even though there is a catch | |
console.log('uncaught error here'); | |
console.log(error); | |
}); | |
var toCall = Promise.coroutine(function* () { | |
console.log('going to explode'); | |
throw new Error('boom'); | |
}); | |
Promise.spawn(function* () { | |
try { | |
console.log('calling the function here'); | |
var val = yield toCall(); | |
} catch(e) { | |
console.log('got an error'); | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment