2015-12-04 01:37:23 +03:00
|
|
|
import Ember from 'ember';
|
|
|
|
|
|
|
|
export default Ember.Mixin.create({
|
|
|
|
actions: {
|
|
|
|
error(error, transition) {
|
2015-12-07 21:37:04 +03:00
|
|
|
if (error.errors && error.errors[0].errorType === 'NotFoundError') {
|
2015-12-04 01:37:23 +03:00
|
|
|
transition.abort();
|
|
|
|
|
|
|
|
let routeInfo = transition.handlerInfos[transition.handlerInfos.length - 1];
|
|
|
|
let router = this.get('router');
|
|
|
|
let params = [];
|
|
|
|
|
|
|
|
for (const key of Object.keys(routeInfo.params)) {
|
|
|
|
params.push(routeInfo.params[key]);
|
|
|
|
}
|
|
|
|
|
|
|
|
return this.transitionTo('error404', router.generate(routeInfo.name, ...params).replace('/ghost/', '').replace(/^\//g, ''));
|
|
|
|
}
|
|
|
|
|
|
|
|
return this._super(...arguments);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|