Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

When will proper stack traces be provided on window.onError function?

Exceptions/Errors in many other programming languages (say java, ruby) always provide stacktrace/backtrace information.

In JavaScript unhandled Errors get caught by window.onError.

Although that function does not get the Error object, so we have no access to the object's stack property.

Is there any reliable source of information about when will there be any change on that?

like image 877
Dimitris Zorbas Avatar asked Jul 16 '13 21:07

Dimitris Zorbas


People also ask

What is a stack trace and what is it useful for?

A stack trace is a report that provides information about program subroutines. It is commonly used for certain kinds of debugging, where a stack trace can help software engineers figure out where a problem lies or how various subroutines work together during execution.

What are the three information provided by Onerror () method?

The Error object and error. It contains 3 standardized properties: message, fileName, and lineNumber.

What is stack traces in JavaScript?

A stack trace is a list of the functions, in order, that lead to a given point in a software program. A stack trace is essentially a breadcrumb trail for your software. You can easily see the stack trace in JavaScript by adding the following into your code: console. trace();


2 Answers

The error object, which would contain a "sanitized" stack trace, is now being passed in as the fifth parameter to onerror in Chrome. You can read about it here: https://code.google.com/p/chromium/issues/detail?id=147127

At the time of this writing it's in Canary and should be pushed out to the stable Chrome release sometime later this month. If you're running Canary you can test it like so:

window.onerror = function (message, file, line, column, errorObj) {     if(errorObj !== undefined) //so it won't blow up in the rest of the browsers         console.log('Error: ' + errorObj.stack); } 

You can see as per the spec that they've also added the column number which IE 10 has also implemented.

You can also checkout the Mozilla discussion: https://bugzilla.mozilla.org/show_bug.cgi?id=355430

like image 199
Brandon Pugh Avatar answered Sep 22 '22 16:09

Brandon Pugh


It seems that the error object itself will be the fifth parameter supplied to onerror. http://html5.org/tools/web-apps-tracker?from=8085&to=8086
http://www.whatwg.org/specs/web-apps/current-work/ - section 7.1.6.1

like image 41
Dimitris Zorbas Avatar answered Sep 24 '22 16:09

Dimitris Zorbas