When will proper stack traces be provided on [removed] function?

前端 未结 2 1836
鱼传尺愫
鱼传尺愫 2020-12-03 16:49

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

In JavaScript unhandled Errors get caught by

2条回答
  •  盖世英雄少女心
    2020-12-03 17:31

    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

提交回复
热议问题