github.com/emate/nomad@v0.8.2-wo-binpacking/ui/app/controllers/application.js (about) 1 import { inject as service } from '@ember/service'; 2 import Controller from '@ember/controller'; 3 import { run } from '@ember/runloop'; 4 import { observer, computed } from '@ember/object'; 5 import Ember from 'ember'; 6 import codesForError from '../utils/codes-for-error'; 7 8 export default Controller.extend({ 9 config: service(), 10 11 error: null, 12 13 errorStr: computed('error', function() { 14 return this.get('error').toString(); 15 }), 16 17 errorCodes: computed('error', function() { 18 return codesForError(this.get('error')); 19 }), 20 21 is403: computed('errorCodes.[]', function() { 22 return this.get('errorCodes').includes('403'); 23 }), 24 25 is404: computed('errorCodes.[]', function() { 26 return this.get('errorCodes').includes('404'); 27 }), 28 29 is500: computed('errorCodes.[]', function() { 30 return this.get('errorCodes').includes('500'); 31 }), 32 33 throwError: observer('error', function() { 34 if (this.get('config.isDev')) { 35 run.next(() => { 36 throw this.get('error'); 37 }); 38 } else if (!Ember.testing) { 39 run.next(() => { 40 // eslint-disable-next-line 41 console.warn('UNRECOVERABLE ERROR:', this.get('error')); 42 }); 43 } 44 }), 45 });