Getting a stack trace from ErrorEvent

1,159 views
Skip to first unread message

Tim Meadowcroft

unread,
Aug 3, 2011, 8:13:51 AM8/3/11
to google-chrome-...@googlegroups.com
Asking the Q here before raising a crbug report in case someone points out it's a stupid idea - not strictly a feature of Developer Tools but close enough related that I hope someone might entertain the question...

Chrome recently got a correct window "error" event (window.onerror or window.addEventListener) which made quite a few of us happy


This means we can now write global error handlers, hence my Chrome extension to add a toolbar button to show such errors when Developer Tools are closed

and a project by @OffBeatMammal to add centralised error logging to your apps when they're in use out in the wild

Now what would make it really handy for these typical uses would be to get the stack trace of the error, which I can do within Chrome at any point using Error.captureStackTrace()
but by the time my window error handler is called, the stack of where the error occurred is lost.

Is it possible (or incredibly dumb) to add something like a "stack" property to the ErrorEvent object (as passed to handlers specified with window.addEventListener) - this would basically be the same as the "stack" property on exception objects, and would make global error handling and logging much richer (another option would be to add a property to the ErrorEvent object of the exception object that would be handed to an exception handler if one were in place).

If the answer is "file a crbug" then I'm happy to do so, but if there's a simple reason why NOT to do so, I'd be interested to know

--
Tim

Yury Semikhatsky

unread,
Aug 3, 2011, 8:56:44 AM8/3/11
to google-chrome-...@googlegroups.com
There have been many requests for this feature and It has already been discussed in the
original bug on window.onerror(https://bugs.webkit.org/show_bug.cgi?id=8519). Now there
is a separate WebKit bug on that: https://bugs.webkit.org/show_bug.cgi?id=55092
We haven't come to an agreement yet on how the API should be changed, whether it is window.onerror
handler that should accept the stack trace as 4th parameter or it is the exception object that should
be passed there. Also there are some security issues associated with passing JS Error object from one
context to an event listener added in a different context should we decide to pass it as a property of ErrorEvent
or as additional parameter of window.onerror. Anyway, you can track the progress at https://bugs.webkit.org/show_bug.cgi?id=55092 As far as I know there is no one actively working on it at the moment.

Yury

Tim Meadowcroft

unread,
Aug 3, 2011, 12:20:16 PM8/3/11
to google-chrome-...@googlegroups.com

Thanks Yury, I scoured crbug for a similar request, but will watch the webkit one instead.
[And thanks for implementing the window error handling that we've got as of Chrome 10 too]

--
T

Reply all
Reply to author
Forward
0 new messages