fix: allow api error interceptor to handle api call failure (#8513)

* letting error interceptor take care of api call failure

* minor fix
This commit is contained in:
Pranav Kanade 2021-10-14 18:38:24 +05:30 committed by GitHub
parent 813af16dba
commit 82c033c785
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 0 deletions

View File

@ -12,6 +12,7 @@ export type ResponseMeta = {
export type ApiResponse = {
responseMeta: ResponseMeta;
data: any;
code?: string;
};
export type GenericApiResponse<T> = {

View File

@ -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));
}