From 82c033c7859732dda1490c0daf51ac460c8906f0 Mon Sep 17 00:00:00 2001 From: Pranav Kanade Date: Thu, 14 Oct 2021 18:38:24 +0530 Subject: [PATCH] fix: allow api error interceptor to handle api call failure (#8513) * letting error interceptor take care of api call failure * minor fix --- app/client/src/api/ApiResponses.tsx | 1 + app/client/src/sagas/ErrorSagas.tsx | 7 +++++++ 2 files changed, 8 insertions(+) diff --git a/app/client/src/api/ApiResponses.tsx b/app/client/src/api/ApiResponses.tsx index 43c781e919..5935f5913b 100644 --- a/app/client/src/api/ApiResponses.tsx +++ b/app/client/src/api/ApiResponses.tsx @@ -12,6 +12,7 @@ export type ResponseMeta = { export type ApiResponse = { responseMeta: ResponseMeta; data: any; + code?: string; }; export type GenericApiResponse = { diff --git a/app/client/src/sagas/ErrorSagas.tsx b/app/client/src/sagas/ErrorSagas.tsx index 50983f4853..85f6503160 100644 --- a/app/client/src/sagas/ErrorSagas.tsx +++ b/app/client/src/sagas/ErrorSagas.tsx @@ -25,6 +25,7 @@ import { } from "constants/messages"; import * as Sentry from "@sentry/react"; +import { axiosConnectionAbortedCode } from "../api/ApiUtils"; /** * making with error message with action name @@ -70,6 +71,12 @@ export function* validateResponse(response: ApiResponse | any, show = true) { if (!response) { throw Error(""); } + + // letting `apiFailureResponseInterceptor` handle it this case + if (response?.code === axiosConnectionAbortedCode) { + return false; + } + if (!response.responseMeta && !response.status) { throw Error(getErrorMessage(0)); }