gpt4 book ai didi

javascript - 如何让javascript错误控制台打印出回调中的错误?

转载 作者:行者123 更新时间:2023-11-28 10:59:26 24 4
gpt4 key购买 nike

如果我在回调之外出现 JavaScript 错误,Firebug 控制台会打印出该错误。但是,如果回调内部出现 Ant 错误,我将看不到任何打印输出。

document.observe('dom:loaded', function() {
// not notified in console
alert(undefinedVariable);
});

// notified in console
alert(anotherUndefinedVariable);

我的几乎所有代码都在回调中,因此这让我很难追踪错误。无论错误发生在哪里,如何在控制台中打印出每个错误?

最佳答案

我需要告诉 Prototype 不要吞掉异常。

Ajax.Responders.register({ 
onException: function(request, exception) {
(function() { throw exception; }).defer();
}
});

关于javascript - 如何让javascript错误控制台打印出回调中的错误?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9089537/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com