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)
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:
intermediateTransitionToso that you don’t get a new URL.modelsargument:this.intermediateTransitionTo('application_error', true);${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
modelargument totransitionTois optional, http://emberjs.com/api/classes/Ember.Route.html#method_transitionToBut, 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.