Commit 46c673b5 by liimin

fix: 添加Sentry错误上报以捕获订单相关异常

在订单列表、详情、物流查询、售后详情等关键操作中添加Sentry错误上报
统一处理HTTP请求失败时的错误上报
修复快递信息组件中的参数校验逻辑并添加错误上报
1 parent f864ef11
...@@ -105,16 +105,18 @@ class Request { ...@@ -105,16 +105,18 @@ class Request {
title: message || '系统异常', title: message || '系统异常',
icon: 'none' icon: 'none'
}) })
wx.p.sentry.reportError(`接口异常:${message}`, {code,message,params})
} }
} }
}, },
fail(error) { fail(error) {
wx.hideLoading() wx.hideLoading()
console.error(`接口异常:`, error)
wx.showToast({ wx.showToast({
title: typeof error == 'string' ? error : JSON.stringify(error) || '系统异常', title: typeof error == 'string' ? error : JSON.stringify(error) || '系统异常',
icon: 'error' icon: 'error'
}) })
console.error(`接口异常:`, error)
wx.p.sentry.reportError(`接口异常:${error.message}`, {error,params})
reject(error) reject(error)
}, },
complete() { complete() {
......
...@@ -71,6 +71,8 @@ Page({ ...@@ -71,6 +71,8 @@ Page({
status, status,
button, button,
}); });
}).catch((err) => {
wx.p.sentry.reportError(`售后详情异常:${err.message}`, {...this.data,err});
}) })
.finally(() => { .finally(() => {
wx.hideLoading(); wx.hideLoading();
...@@ -123,10 +125,13 @@ Page({ ...@@ -123,10 +125,13 @@ Page({
tab: ORDER_STATUS[OrderStatusEnum.COMPLETED], tab: ORDER_STATUS[OrderStatusEnum.COMPLETED],
}); });
} }
}).catch((err) => {
wx.p.sentry.reportError(`撤销售后:${err.message}`, {...this.data.orderInfo,err});
}); });
} }
}) })
.catch(() => { .catch((err) => {
wx.p.sentry.reportError(`撤销售后Modal:${err.message}`, {...this.data.orderInfo,err});
wx.p.wxApi.showToast("已取消"); wx.p.wxApi.showToast("已取消");
}) })
.finally(() => { .finally(() => {
......
...@@ -152,6 +152,7 @@ Component({ ...@@ -152,6 +152,7 @@ Component({
*/ */
processExpressInfo(expressInfo) { processExpressInfo(expressInfo) {
if (!expressInfo || typeof expressInfo !== "object") { if (!expressInfo || typeof expressInfo !== "object") {
wx.p.sentry.reportError(`快递信息异常:expressInfo参数无效`, {expressInfo});
console.warn("Express组件: expressInfo参数无效"); console.warn("Express组件: expressInfo参数无效");
return; return;
} }
...@@ -160,6 +161,7 @@ Component({ ...@@ -160,6 +161,7 @@ Component({
// 验证必要字段 // 验证必要字段
if (typeof logisticsStatus !== "number") { if (typeof logisticsStatus !== "number") {
wx.p.sentry.reportError(`快递信息异常:logisticsStatus字段无效`, {expressInfo});
console.warn("Express组件: logisticsStatus字段无效"); console.warn("Express组件: logisticsStatus字段无效");
return; return;
} }
......
...@@ -37,6 +37,8 @@ Page({ ...@@ -37,6 +37,8 @@ Page({
this.setData({ this.setData({
expressInfo: data, expressInfo: data,
}); });
}).catch((err) => {
wx.p.sentry.reportError(`查询物流异常:${err.message}`, {subOrderCode,err});
}); });
}, },
getOrderDetail(subOrderCode) { getOrderDetail(subOrderCode) {
...@@ -68,6 +70,8 @@ Page({ ...@@ -68,6 +70,8 @@ Page({
}, },
}); });
} }
}).catch((err) => {
wx.p.sentry.reportError(`订单详情异常:${err.message}`, {subOrderCode,err});
}) })
.finally(() => { .finally(() => {
wx.hideLoading(); wx.hideLoading();
......
...@@ -175,6 +175,8 @@ Page({ ...@@ -175,6 +175,8 @@ Page({
list, list,
listFlag: true, listFlag: true,
}); });
}).catch((err) => {
wx.p.sentry.reportError(`订单列表异常:${err.message}`, {...obj,err});
}) })
.finally(() => { .finally(() => {
wx.hideLoading(); wx.hideLoading();
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!