简体   繁体   English

如何禁用YUI2静默失败?

[英]How to disable YUI2 silent failing?

YUI 2 often fails silently, eg when you expect the this to be another object and call an unexisting method on it. YUI 2通常会静默地失败,例如,当您期望this成为另一个对象并在其上调用不存在的方法时。 Is there any way make errors "visible"? 有什么办法可以使错误“可见”?

If your code is running in a YUI event handler, then YUI catches the exception and you won't see it in the debugger. 如果您的代码在YUI事件处理程序中运行,则YUI会捕获该异常,并且您不会在调试器中看到它。

To see these exceptions, you either need to catch the exception yourself and output something to the debug console or turn on the right logging in YUI so it outputs the exceptions. 要查看这些异常,您需要自己捕获异常并将其输出到调试控制台,或者在YUI中打开正确的日志记录以输出异常。 I've looked for the right logging settings to see these exceptions and not found it yet, but it seems like a logical thing that they would support since there are many other logging settings. 我一直在寻找正确的日志记录设置以查看这些异常,但尚未找到它,但是由于还有许多其他日志记录设置,它们似乎会支持这些逻辑上的事情。

One thing you can try is to call this: YAHOO.widget.Logger.enableBrowserConsole() when used with the debug version of the YUI library. 您可以尝试的一件事是调用它:与YUI库的调试版本一起使用时, YAHOO.widget.Logger.enableBrowserConsole() Then, look for debug output in the Firebug, Safari or Chrome console. 然后,在Firebug,Safari或Chrome控制台中查找调试输出。

To answer my own question. 回答我自己的问题。 It's simple as this: 就这么简单:

YAHOO.widget.Logger.enableBrowserConsole();
YAHOO.util.Event.throwErrors = true;

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM