mardi 2 juin 2015

EmberJS / Ember-Data: 404's Not Getting Caught

I am trying to catch 404 errors in my ember app, and redirect to /not-found.

I have an errors action on my ApplicationController, and I have an RSVP.on('error') function too but the 404's aren't getting caught. I just get a 404 error thrown to my console from jQuery, but the error is not getting passed to the error handler.

Console Error

Errors initializer:

import Ember from 'ember';

var initialize = function(container) {
  var errorReporting = container.lookup("service:errorReporting");

  Ember.RSVP.on('error', function(err) {
    Ember.warn("Ember.RSVP error..... Logging error:");
    console.log(err);
    if (err.name && err.name === 'TransitionAborted') {
      Ember.debug("TransitionAborted error. Doesn't look like we should be catching these.");
    } else {
      container.lookup('route:application').send('error', err);
    }
  });

  window.onerror = function(err) { // window general errors.
    Ember.warn("Uncaught error (tripped window.onerror)..... Logging error:");
    console.log(err);
    errorReporting.report(err);
  };

};

export default {
  name: 'errors',
  initialize: initialize
};

The error action on my applicationRoute is huge (and I can post it), but it doesn't even seem to be getting called.




Aucun commentaire:

Enregistrer un commentaire