Hello,
try..catch seems not to catch an exception if it is thrown from a return
statement:
js> nofail = function(f) {
return function() {
try {
return f.apply(this, arguments);
} catch (e) {
return;
}
}
}
js> f = nofail(function() {throw "argh"})
js> f() === undefined
js: "<stdin>", line 98: exception from uncaught JavaScript throw: argh
at <stdin>:98
at <stdin>:99
But if I introduce a variable so as to throw the exception from a
regular statement:
js> nofail = function(f) {
return function() {
try {
var r = f.apply(this, arguments);
return r;
} catch (e) {
return;
}
}
}
js> f = nofail(function() {throw "argh"})
js> f() === undefined
true
It works!
Christophe
_______________________________________________
dev-tech-js-engine-rhino mailing list
[email protected]
https://lists.mozilla.org/listinfo/dev-tech-js-engine-rhino