2020-10-01 08:33:22 +00:00
|
|
|
import Route from 'consul-ui/routing/route';
|
2021-09-15 18:50:11 +00:00
|
|
|
import { action } from '@ember/object';
|
2018-12-04 17:01:59 +00:00
|
|
|
|
|
|
|
import WithBlockingActions from 'consul-ui/mixins/with-blocking-actions';
|
|
|
|
|
2021-09-15 18:50:11 +00:00
|
|
|
export default class ApplicationRoute extends Route.extend(WithBlockingActions) {
|
|
|
|
@action
|
|
|
|
error(e, transition) {
|
|
|
|
// TODO: Normalize all this better
|
|
|
|
let error = {
|
|
|
|
status: e.code || e.statusCode || '',
|
|
|
|
message: e.message || e.detail || 'Error',
|
|
|
|
};
|
|
|
|
if (e.errors && e.errors[0]) {
|
|
|
|
error = e.errors[0];
|
|
|
|
error.message = error.message || error.title || error.detail || 'Error';
|
|
|
|
}
|
|
|
|
if (error.status === '') {
|
|
|
|
error.message = 'Error';
|
|
|
|
}
|
|
|
|
this.controllerFor('application').setProperties({ error: error });
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|