github.com/blixtra/nomad@v0.7.2-0.20171221000451-da9a1d7bb050/ui/app/controllers/application.js (about)

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