# All files / src/Vue index.ts

40% Statements 6/15
0% Branches 0/9
0% Functions 0/3
42.86% Lines 6/14

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
    251x
    1x

    1x
    1x

    1x

    1x

     import { getFlag, setFlag, slientConsoleScope } from '../utils/index'
    import { EVENTTYPES } from '../common/constant'
    import { VueInstance, ViewModel } from './types'
    import { handleVueError } from './helper'
    import { Severity } from '../utils/Severity'

    const hasConsole = typeof console !== 'undefined'

    export const MitoVue = {
      install(Vue: VueInstance): void {
        if (getFlag(EVENTTYPES.VUE) || !Vue || !Vue.config) return
        setFlag(EVENTTYPES.VUE, true)
        // vue 提供 warnHandler errorHandler报错信息
        Vue.config.errorHandler = function (err: Error, vm: ViewModel, info: string): void {
          handleVueError.apply(null, [err, vm, info, Severity.Normal, Severity.Error, Vue])
          if (hasConsole && !Vue.config.silent) {
            slientConsoleScope(() => {
              console.error('Error in ' + info + ': "' + err.toString() + '"', vm)
              console.error(err)
            })
          }
        }
      }
    }