0
Fork 0
mirror of https://github.com/TryGhost/Ghost.git synced 2025-01-27 22:49:56 -05:00

Refactored error controller to Octane patterns

refs https://github.com/TryGhost/Ghost/issues/14101

- migrated to full native class syntax
This commit is contained in:
Kevin Ansfield 2022-10-07 18:05:24 +01:00
parent cefd51c81c
commit a8fb80652c

View file

@ -1,26 +1,21 @@
import Controller from '@ember/controller';
import classic from 'ember-classic-decorator';
import {computed} from '@ember/object';
import {readOnly} from '@ember/object/computed';
@classic
export default class ErrorController extends Controller {
stack = false;
@readOnly('model')
error;
@computed('error.status')
get code() {
return this.get('error.status') > 200 ? this.get('error.status') : 500;
get error() {
return this.error;
}
get code() {
return this.error.status > 200 ? this.error.status : 500;
}
@computed('error.statusText')
get message() {
if (this.code === 404) {
return 'Page not found';
}
return this.get('error.statusText') !== 'error' ? this.get('error.statusText') : 'Internal Server Error';
return this.error.statusText !== 'error' ? this.error.statusText : 'Internal Server Error';
}
}