All files / src/mixins errorable.js

52.94% Statements 9/17
40% Branches 4/10
60% Functions 3/5
52.94% Lines 9/17

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44        1x             1x     1x 1x 1x 1x     1x   1x 1x                                        
import { logger } from '../utility';
 
export default {
  data() {
    return {
      error: {},
      warning: {},
    };
  },
  methods: {
    setError(msg) {
      throw new Error(msg);
    },
    errorHandler(msg, info) {
      const vm = this;
      const error = msg && msg.message ? msg.message : msg;
      const message = 'There was an error rendering the component';
      Iif (info === 'render') {
        vm.error.msg = message;
      } else {
        vm.error.msg = error;
      }
      vm.error.info = info;
      logger.error(error, info);
    },
    warnHandler(msg, info) {
      const vm = this;
      const warning = msg && msg.message ? msg.message : msg;
      vm.warning.msg = warning;
      vm.warning.info = info;
      logger.warn(warning, info);
    },
    renderErrorTemplate() {
      const data = {
        props: {
          type: 'error',
          value: true,
        },
      };
      return this.$createElement('v-alert', data, [this.error.msg]);
    },
  },
};