ember.js: this.transitionTo('error') does nothing and reports nothing

I want to transition to the error route myself. Within routes/application.js I try

actions: {
  customErrorAction: function() {
    this.transitionTo('error');
  }
}

No transition happens, no errors appear in console etc. Almost like it treats it as a no op?

Example twiddle here https://ember-twiddle.com/f2587863883b1019d245.

About this issue

  • Original URL
  • State: closed
  • Created 9 years ago
  • Comments: 18 (11 by maintainers)

Most upvoted comments

Okay, the thing to note here is that error routes actually have dynamic segments.

This means that in order to achieve your goal of reusing the error page you must:

  1. Use intermediateTransitionTo so that you don’t get a new URL.
  2. Pass the second models argument: this.intermediateTransitionTo('application_error', true);
  3. Correctly address the error route name, they’re always ${name}_error.

Should be closed as not a bug. @pixelhandler possibly worth improving documentation for this, but seems more power-user-ish.

@adam-knights well, the api docs do say the model argument to transitionTo is optional, http://emberjs.com/api/classes/Ember.Route.html#method_transitionTo

But, in practice… I’ve found that I either use my own routes as error handing, e.g. ‘not-found’, ‘server-error’ etc. or use the error sub-state default behavior (no call to transition to any ‘error’ sub-state in my code).

There seems to be some ‘special’ handing of the error substates that is not obvious via guides or api docs. Personally I don’t think it is a good practice to mix catching an error and transition to the default error sub-states. This is a portion of the ember codebase that could use some more documentation (guides) and/or improvements to the implementation e.g. using transitionTo('error') in your own code.