try catch 捕获不到异常

原因一:

try中的方法没有抛出异常

原因二:

try中抛出的异常类型不属于catch的异常类或者它的子类

原因三:

try中的方法是异步方法以致于下面catch不到,这种情况可以将异常获取移动到异步方法内部进行处理
   try {
          let res = await competiveUnderEvaluation({ eid: this.$route.query.eid })
          if (res.success) {
            this.netError1 = false
            this.haedData = res.data
            this.animationData = res.data
            this.getScore = true
            console.log(this.getScore, 'this.getScore')
            this.handelAnimationData()
          } else {
            this.netError1 = true
            if (res.code === -100) {
              this.netText = '出故障了,请稍后重试'
            }
          }
        } catch (e) {
          // console.log(455555555);
          this.netError1 = true
        }

里面不能是axios.then的形式,那样会导致捕获不到异常

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值