This may be a stupid question, but I am unable to wrap my head around this.
Consider the following piece of code:
function throwError() {
throw Error("can't touch this.");
}
var def = q.defer();
def.promise.then(
function() {
console.log("no error");
},
function() {
console.log("error");
}
);
q.fcall(throwError).then(def.resolve, def.resolve).done();
In my opinion this should print error
. Instead, it prints no error
.
The q
manual states:
The reject function is a shorthand for resolving with a rejected promise.
q.fcall(throwError)
should produce a rejected promise, so the deferred should be rejected, right?
Please note that this is a purely hypothetical question, I know that this would not be used in the real world.