Skip to content

Instantly share code, notes, and snippets.

@grantcox
Created January 9, 2015 18:52
Show Gist options
  • Save grantcox/4a9a322946f758ad15fe to your computer and use it in GitHub Desktop.
Save grantcox/4a9a322946f758ad15fe to your computer and use it in GitHub Desktop.
'use strict';
var P = require('promise');
P.all([1,2,3]).then(function(results){
console.log('P.all success, results', results);
var a = invalid.property; // oops
console.log('after the invalid property')
}, function(err) {
console.log('P.all error', err);
});
# expected output:
some exception being raised
# actual output:
node exception.js
P.all success, results [ 1, 2, 3 ]
@grantcox
Copy link
Author

grantcox commented Jan 9, 2015

Aha, for the "promise" library I need to chain "catch()", eg:

var P = require('promise');

P.all([1,2,3]).then(function(results){
    console.log('P.all success, results', results);
    var a = invalid.property; // oops
    console.log('after the invalid property')
}, function(err) {
    console.log('P.all error', err);
}).catch(function(err){
    console.log('some error occurred', err);
});

#output:
node exception.js
P.all success, results [ 1, 2, 3 ]
some error occurred [ReferenceError: invalid is not defined]

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