How can I get break on runtime exception(or error) in javascript (or ecmascript?)

感情迁移 提交于 2020-01-24 14:46:09

问题


How can I break on error?

I have a code:

throw new Error("Some error");

And I'm using most recent version of Web Inspector (Webkit) and Firebug(Mozilla). These tools catch and print the error, but does not break. May I don't know the how to. Please let me know how can I to do these?


回答1:


In WebKit you need to click this to enable break on error. If you click it again it will also break on warnings and clicking it again will disable it.

alt text http://a.yfrog.com/img832/3580/screenshot20100723at101.png




回答2:


I redefined Error to get solution.

    var Error   =   function(v)
    {
        console.trace();
        console.debug(v);
    }

This solved my problem.



来源:https://stackoverflow.com/questions/3315675/how-can-i-get-break-on-runtime-exceptionor-error-in-javascript-or-ecmascript

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!