I’ve got the following code:
try {
...
try {
// This is *never* called
alert('TRY');
} catch (e) {
// But this *is* called
alert('CATCH');
}
} catch (e2) {
...
}
The problem is, the alert from the inner catch block is executed but not the one from the inner try.
Is this possible at all per specification or does anyone have an idea what is happening here ?
Can an exception from e.g. asynchronous code run into the context of another catch block ?
Note this is real code I put in there, no omissions in the inner try / catch !
Some asynchronous code may be run before entering the block.
This is from code taken from a web app running in WebKit / QtWebKit from PyQt 4.9.0 and Qt 4.8.0.
Ok, so here some more code before the inner try/catch (where the first ellipsis is):
DoSomething(function () {
var updatePromises = [];
var p;
for (...) {
p = new Promise();
updatePromises.push(p);
// Run asynchronous code to fulfill promise.
// Calls are chained using an array and a "setTimeout()" mechanism.
tasks.chain(function (promise) { ... }, this, p);
}
(function () {
...
}).future().apply(this, updatePromises);
}.bind(this));
The ES5 specification says the following (emphasis added):
My understanding of that is that, according to the spec, there is no way a catch block can be executed without first evaluating the try block.