mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-12-21 09:52:06 +03:00
9baa34500b
no issue - add a check for existence of `error.errors` as that won't be present on non-404 errors - fixes non-404 errors such as "no action handled x" being hidden by a completely different error
24 lines
772 B
JavaScript
24 lines
772 B
JavaScript
import Ember from 'ember';
|
|
|
|
export default Ember.Mixin.create({
|
|
actions: {
|
|
error(error, transition) {
|
|
if (error.errors && error.errors[0].errorType === 'NotFoundError') {
|
|
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);
|
|
}
|
|
}
|
|
});
|