Eeek, how embarrassing. This seems to have been fixed while I wasn't looking, 
and/or my testing wasn't as complete as I thought. I should have re-tested 
before emailing. My apologies for wasting everyone's time.

The debugger step-back-ability isn't there in Chrome, at least, but that's a 
much smaller problem.

________________________________
From: Rick Waldron [[email protected]]
Sent: Friday, May 11, 2012 16:10
To: Brendan Eich
Cc: Domenic Denicola; [email protected]
Subject: Re: Re-throwing errors



On Fri, May 11, 2012 at 2:43 PM, Brendan Eich 
<[email protected]<mailto:[email protected]>> wrote:
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?

This is fascinating, but I can't reproduce - can you confirm: 
https://gist.github.com/2662158


Rick



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]<mailto:[email protected]>
https://mail.mozilla.org/listinfo/es-discuss
_______________________________________________
es-discuss mailing list
[email protected]<mailto:[email protected]>
https://mail.mozilla.org/listinfo/es-discuss

_______________________________________________
es-discuss mailing list
[email protected]
https://mail.mozilla.org/listinfo/es-discuss

Reply via email to