| 61 | // 有的用 texts / message / error,兜底才使用 axios 本身的 err.message(如 "Request failed with status code 403") |
| 62 | const data: any = err.response?.data; |
| 63 | const pickMsg = (d: any): string | undefined => { |
| 64 | if (!d) return undefined; |
| 65 | if (typeof d === 'string') return d; |
| 66 | if (typeof d !== 'object') return undefined; |
| 67 | // 优先顺序:nonce(业务错误文案) > texts > message > error > msg |
| 68 | return d.nonce || d.texts || d.message || d.error || d.msg; |
| 69 | }; |
| 70 | const bizMsg = pickMsg(data); |
| 71 | const finalMsg = bizMsg || err.message || '网络异常,请稍后重试'; |
| 72 | |