Skip to content

Instantly share code, notes, and snippets.

@pc035860
Forked from geekingfrog/excetion in coroutine
Created January 25, 2014 05:54
Show Gist options
  • Save pc035860/8612404 to your computer and use it in GitHub Desktop.
Save pc035860/8612404 to your computer and use it in GitHub Desktop.
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', error);
});
var toCall = Promise.coroutine(function* () {
console.log('going to explode');
throw new Error('boom');
});
Promise.spawn(function* () {
console.log('calling the function here');
var val = yield toCall();
})
.catch(function (error) {
console.log('got an error', error);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment