Domenic Denicola wrote:
Consider:
try {
doStuff();
} catch (e) {
console.log("uh oh, got an e", e);
throw e;
}
In Node and in all browsers I've tested with, this currently loses the
stack trace for `e`, and more importantly loses debugger
step-back-ability in tools like Firebug and Web Inspector.
One solution would be to hope V8 and the browser vendors simply don't
throw away this stack trace, like they do currently. This seems like a
win to me, but the fact that it hasn't happened implies there must be
something wrong with the idea, e.g. maybe it breaks down in
less-than-trivial cases. Is that true?
So V8 overwrites e.stack on the re-throw?
SpiderMonkey does not:
js> function f() {
try {
doStuff();
} catch (e) {
console.log("uh oh, got an e", e);
throw e;
}
}
js> function g() {f()}
js> function h() {g()}
js> function doStuff() {uh.oh}
js> console = {log: print}
({log:function print() {[native code]}})
js> try {h()}catch (e){E=e}
uh oh, got an e ReferenceError: uh is not defined
(new ReferenceError("uh is not defined", "typein", 11))
js> e.stack
typein:15: ReferenceError: e is not defined
js> E.stack
"doStuff@typein:11\nf@typein:3\ng@typein:9\nh@typein:10\n@typein:14\n"
Since the explicit re-throw is not creating the exception object, it
should not be mutating it to clobber the original .stack value.
/be
If so, then in C++ and C# they solve this by saying that an empty
`throw` is an explicit re-propagation [1]. Would this be a possible
feature to introduce into Harmony?
[1]: http://winterdom.com/2002/09/rethrowingexceptionsinc
_______________________________________________
es-discuss mailing list
[email protected]
https://mail.mozilla.org/listinfo/es-discuss
_______________________________________________
es-discuss mailing list
[email protected]
https://mail.mozilla.org/listinfo/es-discuss