在延迟的回调中不会抛出/显示任何错误 [英] No errors thrown/displayed when in a deferred callback

查看:59
本文介绍了在延迟的回调中不会抛出/显示任何错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们正在使用RequireJS和Node构建一个项目,并在服务器端和客户端复用模块.到目前为止,一切都很好(可以解决一些小问题).

We're building a project with RequireJS and Node, and reusing modules both server and client side. It's going pretty good so far (some small kinks to work out).

一个问题似乎是,延迟的回调中的错误永远不会显示在节点控制台中(或与此相关的任何其他方式).使其很难调试.

An issue seems to be that errors inside a deferred callback don't ever get displayed in the node console (or in any other way for that matter). Making it very hard to debug.

asdasdasd(); // Throws error, function is undefined, as intended
this.loadOrganization(organization_key, true).then(function(org) {
    asdasdasd(); // No error anywhere, script just stops executing
});

loadOrganization返回一个延迟的对象,并且回调被调用为精细-但是,不会显示与未定义有关的错误消息(在评估模块时,节点会报告一般语法错误).

loadOrganization returns a deferred object, and the callback gets called fine - However no error messages pertaining to undefined are displayed (general syntax errors are reported by node when evaluating the module).

我们使用jsdom和jquery在服务器端为浏览器引导内容.然后将jsdon中的jquery传递给大多数方法-因此,用于loadOrganization的延迟对象是jQuery中通过jsdom传递的对象.将npm已安装的jquery中的deferred更改为一个,但是没有区别.

We bootstrap content for the browser on the serverside using jsdom with jquery. And then pass the jquery from jsdon to most methods - So the deferred object used for the loadOrganization is the one from jQuery via jsdom. Changing the deferred used to one from npm installed jquery however makes no difference.

任何建议都是有帮助的,当没有打印错误时,很难调试.

Any suggestions would be helpful, its pretty hard to debug when there are no errors printed.

推荐答案

弄清楚,它是服务器端Backbone.Sync实现中的一个野生try/catch语句.这意味着通过API的所有内容(几乎所有内容)都被try/catch捕获,该尝试将错误传递给Backbone.Sync错误回调,并且再也没有听到过.

Figured it out, was a wild try/catch statement in our Backbone.Sync implementation on the serverside. Which meant that anything going through the API (which is pretty much anything) was being caught by a try/catch that passed the error on to the Backbone.Sync error callback, and was never heard from again.

这个故事太寓意了;如果没有错误输出,请遍历您的代码以进行尝试/捕获.

So moral of the story; Look through your code for Try/Catches if no errors are outputted.

这篇关于在延迟的回调中不会抛出/显示任何错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆