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 = [];
|
|
|
|
|
2016-04-08 18:00:16 +03:00
|
|
|
for (let key of Object.keys(routeInfo.params)) {
|
2015-12-04 01:37:23 +03:00
|
|
|
params.push(routeInfo.params[key]);
|
|
|
|
}
|
|
|
|
|
|
|
|
return this.transitionTo('error404', router.generate(routeInfo.name, ...params).replace('/ghost/', '').replace(/^\//g, ''));
|
|
|
|
}
|
|
|
|
|
|
|
|
return this._super(...arguments);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|