I have the following chained functions that all implement promises utilizing Q:
validateToken(context).then(parseFormData, get403).then(createReport, get400).then(send200, get400).catch(get500);
e.g. All of them have somewhere within them:
let deferred = q.defer();
..
deferred.resolve(true);
deferred.reject(false);
return deferred.promise;
The first function validateToken calls a deferred.reject. This then results with get403 being called, as expected; but createReport, get400 and get500 are also being called? This confuses me. I thought only the first error handler was hit in the chain?
Can someone please explain what is happening, and if there is a way for me to get the desired behavior where only the most immediate reject/error handler is called?