and I return an error from the server, the error handler is never called.
The problem is related to this line: https://github.com/voryx/angular-wamp/blob/master/src/angular-wamp.js#L311. Indeed, the error part of the Then() is not linked as it should be. The angular doc about $q states that we should use return $q.reject(); in the error block to pass to the next error block. In your case, after the first error block, since we don't call return $q.reject(reason);, the next block is the success one.
Example of chaining:
promiseB = promiseA.then(function(result) {
// success: do something and resolve promiseB
// with the old or a new result
return result;
}, function(reason) {
// error: handle the error if possible and
// resolve promiseB with newPromiseOrValue,
// otherwise forward the rejection to promiseB
if (canHandle(reason)) {
// handle the error and recover
return newPromiseOrValue;
}
return $q.reject(reason);
});
I have noticed that if I use this code:
and I return an error from the server, the error handler is never called.
The problem is related to this line: https://github.com/voryx/angular-wamp/blob/master/src/angular-wamp.js#L311. Indeed, the error part of the Then() is not linked as it should be. The angular doc about
$q
states that we should usereturn $q.reject();
in the error block to pass to the next error block. In your case, after the first error block, since we don't callreturn $q.reject(reason);
, the next block is the success one.Example of chaining: