From a2ad9f8f5fc97255832e40e3ff58278a23695e0f Mon Sep 17 00:00:00 2001 From: martian56 Date: Sun, 5 Jul 2026 13:55:07 +0400 Subject: [PATCH] fix(ui): preserve AxiosError in the response interceptor The global response interceptor rejected with a fresh Error(message), throwing away the original AxiosError and with it response, status, and data. Call sites that branch on those fields silently stopped working: GitHub sync errored instead of showing the not-linked empty state, and several forms fell back to a generic message instead of the backend's specific one. Attach the friendly text to error.message and reject the original error so status- and body-based handling keeps working. Co-Authored-By: Claude Opus 4.8 (1M context) --- apps/web/src/api/client.ts | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/apps/web/src/api/client.ts b/apps/web/src/api/client.ts index cadadfef..8eab7708 100644 --- a/apps/web/src/api/client.ts +++ b/apps/web/src/api/client.ts @@ -108,7 +108,10 @@ export function getApiErrorMessage(err: unknown): string { apiClient.interceptors.response.use( (response) => response, (error: AxiosError) => { - const message = getApiErrorMessage(error); - return Promise.reject(new Error(message)); + // Attach a user-facing message but keep rejecting the original AxiosError so + // callers can still branch on error.response / error.response.status / + // error.response.data. Replacing it with a bare Error dropped those fields. + error.message = getApiErrorMessage(error); + return Promise.reject(error); }, );