Skip to content

Instantly share code, notes, and snippets.

@geekingfrog
Created January 25, 2014 04:49
Show Gist options
  • Select an option

  • Save geekingfrog/8612025 to your computer and use it in GitHub Desktop.

Select an option

Save geekingfrog/8612025 to your computer and use it in GitHub Desktop.

Revisions

  1. geekingfrog created this gist Jan 25, 2014.
    22 changes: 22 additions & 0 deletions excetion in coroutine
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,22 @@
    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');
    }
    });