Ember.js sometimes not showing errors

不问归期 提交于 2020-01-15 05:52:50

问题


Sometimes the ember app crashes, normally when I do something at an earlier stage, but I haven't really seen a pattern - and no error is logged to the console.

I can see the error if I set a break point to TRY_CATCH_ERROR.error = e; somewhere in the guts of the rendered app - but there has to be a simpler way I guess.


回答1:


All errors:

Ember.onerror = function(error) {
   console.log(error)
}

Implement an Ember.onerror hook to log all errors in production


For Promises:

Ember.RSVP.on('error', function(error) {
  Ember.Logger.assert(false, error);
});

Errors within an RSVP.Promise


Run loop stack traces

Ember.run.backburner.DEBUG = true;

Errors within Ember.run.later (Backburner.js)




回答2:


I had an app which also swallowed the error logging; even adding the Ember.onerror function described by @Kingpin2k did not help.

After debugging I found the problem. I used the error event in my Application route to do some custom stuff if a 404 was thrown:

export default Ember.Route.extend({
    actions: {
        error(e) {
            if (Ember.isArray(adapterError.errors) && adapterError.errors[0].status === '404') {
                //do stuff
            }
        }
    }
});

I forgot to add return true if above statement is not true. Forgetting such things practically removes the error logging, because the bubble-event-chain is broken.



来源:https://stackoverflow.com/questions/25915345/ember-js-sometimes-not-showing-errors

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