From f3d60d09ed0505bb061d12ca3fbd43ad4ed57769 Mon Sep 17 00:00:00 2001 From: Ryan Wang Date: Thu, 25 Apr 2024 11:57:26 +0800 Subject: [PATCH] feat: catch http request error Signed-off-by: Ryan Wang --- ui/src/utils/api-client.ts | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/ui/src/utils/api-client.ts b/ui/src/utils/api-client.ts index 68efb6bfef..f875cffecd 100644 --- a/ui/src/utils/api-client.ts +++ b/ui/src/utils/api-client.ts @@ -116,6 +116,13 @@ axiosInstance.interceptors.response.use( return Promise.reject(error); } + // Final fallback + if (errorResponse.status) { + const { status, statusText } = errorResponse; + Toast.error([status, statusText].filter(Boolean).join(": ")); + return Promise.reject(error); + } + Toast.error(i18n.global.t("core.common.toast.unknown_error")); return Promise.reject(error);