[英]Javascript: Errors arent being displayed on event listeners
I have a problem that is driving me crazy. 我有一个使我疯狂的问题。 I have two event listeners that appear to be identical.
我有两个似乎相同的事件侦听器。 The are being called with the same scope but at different times.
的调用范围相同,但时间不同。 I have been using chromes debugger tool to step through them.
我一直在使用chromes调试器工具来逐步调试它们。 The first one will throw an error
第一个会抛出错误
TypeError: Object 1 has no method 'get'
But the second example simple stops executing 但是第二个示例简单地停止执行
el.on("change:one", function() {
debugger;
a = 1;
a.get();
});
el.on("change:two", function() {
debugger;
a = 1;
a.get();
});
I understand that simple asking why is this happening probably needs a detailed explanation of all the libraries being used etc, so my question is: 我知道,简单地询问为什么会发生这种情况可能需要对所有正在使用的库等进行详细说明,所以我的问题是:
Is it possible to not display errors thrown by javascript, and how would I be able to detect whether something is overriding the error reporting functionality 是否可能不显示javascript引发的错误,以及我如何能够检测到某些内容是否覆盖了错误报告功能
NOTE: In both examples I have determined that window.onerror
is null
注意:在两个示例中,我都已确定
window.onerror
为null
Backbone invokes event handlers synchronously and doesn't catch handler exceptions. 骨干网会同步调用事件处理程序,并且不会捕获处理程序异常。 So if you had code that looked like:
因此,如果您的代码如下所示:
el.trigger('change:one'); // handler will throw exception
el.trigger('change:two'); // won't execute
The change:two
event will never get triggered, resulting in your change:two
handler never getting invoked. change:two
事件将永远不会被触发,从而导致您的change:two
处理程序永远不会被调用。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.