I have something like:
var a = somePromise.then(function() {
throw 1;
})
.catch(function() {
return new PromiseReturningThing();
});
a.catch(function() {alert('err');}); // inside is never called, although I know there is an error
Let's assume that the PromiseReturningThing()
returns a promise which will itself throw an exception.
With the above code there is no alert showing up. But using this code, it works:
var a = new PromiseReturningThing();
a.catch(function() {alert('err');});
Is there a fundamental thing I did not understand? I couldn't find any example on the net, but I think that it is possible to return promises in catch-blocks.
PromiseReturningThing()
is actually PouchDB(), if you're wondering. And the promises in the first snippet are some authentification routines.
I am using Chrome v37.0.2062.120
Thanks in advance!
EDIT
Also weird: if I return null
in the first snippet at the place where return new PromiseReturningThing();
is, a.catch doesn't throw an a is undefined
exception in Chrome. Why that?