美文网首页
try catch中err对象的类型

try catch中err对象的类型

作者: 冰点雨 | 来源:发表于2024-05-27 15:52 被阅读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'

相关文章

网友评论

      本文标题:try catch中err对象的类型

      本文链接:https://www.haomeiwen.com/subject/jsocqjtx.html