Skip to content

Commit 22a908e

Browse files
authored
fix: enhance error handling in axios interceptor for fallback responses by directly throwing OneKeyServerApiError (#7592)
1 parent 1cb77f3 commit 22a908e

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

packages/shared/src/request/axiosInterceptor.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -211,6 +211,11 @@ axios.interceptors.response.use(
211211

212212
return fallbackResponse;
213213
} catch (fallbackError) {
214+
// If fallback error is a OneKeyServerApiError (business error), throw it directly
215+
if (fallbackError instanceof OneKeyServerApiError) {
216+
throw fallbackError;
217+
}
218+
214219
// If fallback also fails, continue with original error handling
215220
console.warn(
216221
'Business error fallback request also failed:',
@@ -350,6 +355,11 @@ axios.interceptors.response.use(
350355

351356
return fallbackResponse;
352357
} catch (fallbackError) {
358+
// If fallback error is a OneKeyServerApiError (business error), throw it directly
359+
if (fallbackError instanceof OneKeyServerApiError) {
360+
throw fallbackError;
361+
}
362+
353363
// If fallback also fails, continue with original error handling
354364
console.warn('Fallback request also failed:', fallbackError);
355365
}

0 commit comments

Comments
 (0)