I'm under the impression that an exception inside a promise will trigger the subsequent fail-handler, but I'm not seeing it happen in this code:
var Q = require('q');
function x() {
console.log('x');
var deferred = Q.defer();
setTimeout(
function() {
console.log('resolving x');
deferred.resolve('hi');
},
1000
);
return deferred.promise;
}
function y() {
console.log('y');
var deferred = Q.defer();
setTimeout(
function() {
console.log('throwing in y');
throw new Error('Oih!');
},
1000
);
return deferred.promise;
}
x().then(y).then(
function () {
console.log('yes');
},
function () {
console.log('no');
}
);
Am I doing something wrong, or have I misunderstood?