# All files / utils exception.ts

100% Statements 6/6
50% Branches 1/2
100% Functions 1/1
100% Lines 6/6

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

    7x
    3x
    3x

    1x
    1x
    1x

     import { voidFun } from '../common/constant'

    /**
     * 原生try函数
     * ../param fn try中执行的函数体
     * ../param errorFn 报错时执行的函数体，将err传入
     */
    export function nativeTryCatch(fn: voidFun, errorFn?: (err: any) => void): void {
      try {
        fn()
      } catch (err) {
        console.log('err', err)
        Eif (errorFn) {
          errorFn(err)
        }
      }
    }