From 2f62794be6169c6de4104a9c2b65412ebc6eb30f Mon Sep 17 00:00:00 2001 From: matevip Date: Fri, 8 May 2026 15:09:23 +0800 Subject: [PATCH] fix(ui/api): axios interceptor preserves response body on rejection --- mateclaw-ui/src/api/index.ts | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/mateclaw-ui/src/api/index.ts b/mateclaw-ui/src/api/index.ts index 85bb5ca6..83348804 100644 --- a/mateclaw-ui/src/api/index.ts +++ b/mateclaw-ui/src/api/index.ts @@ -53,7 +53,15 @@ http.interceptors.response.use( if (err.response?.status === 401) { handleAuthFailure() } - return Promise.reject(err.response?.data?.msg || err.message) + // Wrap as Error so consumers can read e.message uniformly, but preserve + // err.response so callers needing the structured payload (e.g. workflow + // compile errors → response.data.data.errors[]) can still reach it. + // The previous shape rejected with a bare string, which silently + // stripped the body and made 422-class errors look like "no response" + // on the publish/compile flows. + const wrapped = new Error(err.response?.data?.msg || err.message || 'Request failed') + ;(wrapped as Error & { response?: unknown }).response = err.response + return Promise.reject(wrapped) } )