github.com/iqoqo/nomad@v0.11.3-0.20200911112621-d7021c74d101/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 import NoLeaderError from '../utils/no-leader-error'; 8 9 export default Controller.extend({ 10 config: service(), 11 system: service(), 12 13 queryParams: { 14 region: 'region', 15 }, 16 17 region: null, 18 19 error: null, 20 21 errorStr: computed('error', function() { 22 return this.error.toString(); 23 }), 24 25 errorCodes: computed('error', function() { 26 return codesForError(this.error); 27 }), 28 29 is403: computed('errorCodes.[]', function() { 30 return this.errorCodes.includes('403'); 31 }), 32 33 is404: computed('errorCodes.[]', function() { 34 return this.errorCodes.includes('404'); 35 }), 36 37 is500: computed('errorCodes.[]', function() { 38 return this.errorCodes.includes('500'); 39 }), 40 41 isNoLeader: computed('error', function() { 42 const error = this.error; 43 return error instanceof NoLeaderError; 44 }), 45 46 throwError: observer('error', function() { 47 if (this.get('config.isDev')) { 48 run.next(() => { 49 throw this.error; 50 }); 51 } else if (!Ember.testing) { 52 run.next(() => { 53 // eslint-disable-next-line 54 console.warn('UNRECOVERABLE ERROR:', this.error); 55 }); 56 } 57 }), 58 });