try catch中err对象的类型

2024-05-27  本文已影响0人  冰点雨
.catch((err:BusinessError)=>{
    console.log('——————————————— 请求失败 ————————————————\n'+ '请求地址:' + url  + '\n请求参数:' +JSON.stringify(jsonStr)+ '\n请求错误:'+`${err}`);
    console.log('err:'+`${err}`)
    response.Message = err.message;
    response.Code = err.code;
    return response;
  })

在高版本中,必须指定类型,arkts中是使用的BusinessError ,不过要高版本中import { BusinessError } from '@ohos.base'

上一篇 下一篇

猜你喜欢

热点阅读