From f0be4341f3bc4a2b6d0b268ed9b9100a430103d3 Mon Sep 17 00:00:00 2001 From: akash-codemonk <67054171+akash-codemonk@users.noreply.github.com> Date: Fri, 19 Feb 2021 11:16:54 +0530 Subject: [PATCH] Fix execute action error message (#3077) --- app/client/src/api/Api.tsx | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/app/client/src/api/Api.tsx b/app/client/src/api/Api.tsx index cfc9661605..5d109301fb 100644 --- a/app/client/src/api/Api.tsx +++ b/app/client/src/api/Api.tsx @@ -9,7 +9,11 @@ import { ActionApiResponse } from "./ActionAPI"; import { AUTH_LOGIN_URL } from "constants/routes"; import history from "utils/history"; import { convertObjectToQueryParams } from "utils/AppsmithUtils"; -import { ERROR_500, SERVER_API_TIMEOUT_ERROR } from "../constants/messages"; +import { + ERROR_0, + ERROR_500, + SERVER_API_TIMEOUT_ERROR, +} from "../constants/messages"; //TODO(abhinav): Refactor this to make more composable. export const apiRequestConfig = { @@ -51,10 +55,19 @@ axiosInstance.interceptors.response.use( return response.data; }, function(error: any) { + // Return error when there is no internet + if (!window.navigator.onLine) { + return Promise.reject({ + ...error, + message: ERROR_0, + }); + } + // Return if the call was cancelled via cancel token if (axios.isCancel(error)) { return; } + // Return modified response if action execution failed if (error.config && error.config.url.match(executeActionRegex)) { return makeExecuteActionResponse(error.response);