fix(common): useRequest.fetchAsync 不再重复包装响应拦截器已处理的 RequestError
响应拦截器(如 useApi.ts 中的错误转换)产生的 RequestError 会被
fetchAsync 的 catch 块再次包装为 RequestError('网络请求失败', 'OtherError'),
导致原始的服务器错误消息(如"系统异常")丢失。
现在当 catch 块收到的错误已经是 RequestError 时,直接透传而不重新包装,
保留拦截器中已经提取好的错误消息。
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
这个提交包含在:
父节点
51e016e185
当前提交
988582e9df
@ -202,6 +202,14 @@ export function useRequest<
|
|||||||
} catch (e: unknown) {
|
} catch (e: unknown) {
|
||||||
clearTimeout(timer)
|
clearTimeout(timer)
|
||||||
|
|
||||||
|
// If a response interceptor already produced a RequestError, pass it through
|
||||||
|
// rather than re-wrapping it and losing the original message.
|
||||||
|
if (e instanceof RequestError) {
|
||||||
|
_notifyApiError(e)
|
||||||
|
dispatch({ type: 'reject', error: e })
|
||||||
|
return Promise.reject(e)
|
||||||
|
}
|
||||||
|
|
||||||
let wrapped: RequestError
|
let wrapped: RequestError
|
||||||
|
|
||||||
if (isCancel(e)) {
|
if (isCancel(e)) {
|
||||||
|
|||||||
正在加载...
在新工单中引用
屏蔽一个用户