feat: 接口错误处理增强,统一打印并展示后端错误信息

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
17792275749
2026-09-01 16:57:28 +08:00
co-authored by Claude Sonnet 4.6
parent 85523109f6
commit 8d69249147
6 changed files with 31 additions and 20 deletions
@@ -167,8 +167,9 @@ Page({
hasData: list.length > 0,
})
})
.catch(() => {
wx.showToast({ title: '加载用户列表失败', icon: 'none' })
.catch((err: any) => {
console.error('[userManagement] 加载用户列表失败:', err)
wx.showToast({ title: err?.msg || err?.message || '加载用户列表失败', icon: 'none' })
})
},
@@ -295,8 +296,9 @@ Page({
// 先读设备端主用户列表,判断设备是否已有主用户
leFuService.fetchDeviceUserIds()
.then((deviceUserIds) => this._syncUsers(pendingUsers, deviceUserIds))
.catch(() => {
wx.showToast({ title: '读取设备用户失败', icon: 'none' })
.catch((err: any) => {
console.error('[userManagement] 读取设备用户失败:', err)
wx.showToast({ title: err?.message || '读取设备用户失败', icon: 'none' })
})
},
@@ -414,8 +416,9 @@ Page({
wx.showToast({ title: '删除成功', icon: 'success' })
this._loadMembers()
})
.catch(() => {
wx.showToast({ title: '删除失败,请重试', icon: 'none' })
.catch((err: any) => {
console.error('[userManagement] 删除成员失败:', err)
wx.showToast({ title: err?.msg || err?.message || '删除失败,请重试', icon: 'none' })
})
},
})
@@ -452,8 +455,9 @@ Page({
wx.showToast({ title: '添加成功', icon: 'success' })
this._loadMembers()
})
.catch(() => {
wx.showToast({ title: '添加失败,请重试', icon: 'none' })
.catch((err: any) => {
console.error('[userManagement] 添加本人失败:', err)
wx.showToast({ title: err?.msg || err?.message || '添加失败,请重试', icon: 'none' })
})
},