NTP-27695 | RN Pages Network Error (#14517)
This commit is contained in:
@@ -29,6 +29,7 @@ const QuoteOfferErrorScreen = ({
|
||||
};
|
||||
const errorResponse = getErrorResponseFromStatusCode(
|
||||
errorMetaData?.errorStatusCode,
|
||||
errorMetaData?.errorAxiosCode,
|
||||
);
|
||||
return (
|
||||
<View style={styles.container}>
|
||||
|
||||
@@ -16,6 +16,7 @@ export interface GenericActionPayload {
|
||||
|
||||
export interface ErrorMetaData extends GenericActionPayload {
|
||||
errorStatusCode?: number;
|
||||
errorAxiosCode?: string;
|
||||
}
|
||||
|
||||
export interface ActionMetaData {
|
||||
|
||||
@@ -9,3 +9,6 @@ export const STATUS_CODE_TIMEOUT = 408;
|
||||
export const STATUS_CODE_CONFLICT = 409;
|
||||
export const STATUS_CODE_GATEWAY_TIMEOUT = 504;
|
||||
export const STATUS_CODE_TOO_MANY_REQUESTS = 429;
|
||||
|
||||
export const AXIOS_CODE_NETWORK = "ERR_NETWORK";
|
||||
export const AXIOS_CODE_CANCELED = "ERR_CANCELED";
|
||||
|
||||
@@ -11,6 +11,8 @@ import {
|
||||
} from "../../Container/Navi-Insurance/network";
|
||||
import { ActionMetaData, BaseActionTypes } from "../actions/GenericAction";
|
||||
import {
|
||||
AXIOS_CODE_CANCELED,
|
||||
AXIOS_CODE_NETWORK,
|
||||
AnalyticsEventNameConstants,
|
||||
AnalyticsModuleNameConstant,
|
||||
EVENT_NAMES,
|
||||
@@ -112,12 +114,16 @@ export const handleErrorData = (
|
||||
moduleName: AnalyticsModuleNameConstant.GI,
|
||||
flowName,
|
||||
methodName: methodName,
|
||||
globalErrorType: getErrorTypeFromStatusCode(error.statusCode || -1),
|
||||
globalErrorType: getErrorTypeFromStatusCode(error.statusCode),
|
||||
isAppDowntimeEvent: false,
|
||||
errorCode: error.axiosCode,
|
||||
errorTitle: getErrorTitleFromError(error.statusCode || -1),
|
||||
errorTitle: getErrorTitleFromError(error.statusCode, error.axiosCode),
|
||||
latency: latency,
|
||||
isNae: error.statusCode === 20 ? false : true,
|
||||
isNae: !(
|
||||
error.statusCode === 20 ||
|
||||
error.axiosCode === AXIOS_CODE_NETWORK ||
|
||||
error.axiosCode === AXIOS_CODE_CANCELED
|
||||
),
|
||||
apiUrl: apiUrl,
|
||||
apiMethod: apiMethod,
|
||||
};
|
||||
@@ -133,6 +139,7 @@ export const handleErrorData = (
|
||||
screenMetaData,
|
||||
],
|
||||
errorStatusCode: error.statusCode,
|
||||
errorAxiosCode: error.axiosCode,
|
||||
},
|
||||
};
|
||||
setScreenData(updatedScreenData);
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
import {
|
||||
AXIOS_CODE_CANCELED,
|
||||
AXIOS_CODE_NETWORK,
|
||||
AnalyticsGlobalErrorTypeConstant,
|
||||
ERROR_INTERNET_SUBTITLE,
|
||||
ERROR_INTERNET_TITLE,
|
||||
@@ -9,20 +11,30 @@ import {
|
||||
} from "../constants";
|
||||
import { ErrorResponse } from "../interface/components/ErrorResponse";
|
||||
|
||||
export const getErrorTypeFromStatusCode = (statusCode: number) => {
|
||||
export const getErrorTypeFromStatusCode = (statusCode?: number) => {
|
||||
const statusCodeforGenericError = [20, 23, 24, 401, 404];
|
||||
|
||||
if (statusCodeforGenericError.includes(statusCode) || statusCode >= 500) {
|
||||
if (
|
||||
statusCode &&
|
||||
(statusCodeforGenericError.includes(statusCode) || statusCode >= 500)
|
||||
) {
|
||||
return AnalyticsGlobalErrorTypeConstant.GLOBAL_GENERIC_ERRORS;
|
||||
}
|
||||
|
||||
return AnalyticsGlobalErrorTypeConstant.GLOBAL_INTERNAL_ERRORS;
|
||||
};
|
||||
|
||||
export const getErrorTitleFromError = (statusCode: number) => {
|
||||
export const getErrorTitleFromError = (
|
||||
statusCode?: number,
|
||||
axiosCode?: string,
|
||||
) => {
|
||||
const statusCodeforInternetIssues = [20, 21, 23, 24];
|
||||
|
||||
if (statusCodeforInternetIssues.includes(statusCode)) {
|
||||
if (
|
||||
(statusCode && statusCodeforInternetIssues.includes(statusCode)) ||
|
||||
axiosCode === AXIOS_CODE_NETWORK ||
|
||||
axiosCode === AXIOS_CODE_CANCELED
|
||||
) {
|
||||
return ERROR_INTERNET_TITLE;
|
||||
}
|
||||
|
||||
@@ -31,6 +43,7 @@ export const getErrorTitleFromError = (statusCode: number) => {
|
||||
|
||||
export const getErrorResponseFromStatusCode = (
|
||||
statusCode?: number,
|
||||
axiosCode?: string,
|
||||
): ErrorResponse => {
|
||||
switch (statusCode) {
|
||||
case STATUS_CODE_NO_INTERNET:
|
||||
@@ -40,10 +53,20 @@ export const getErrorResponseFromStatusCode = (
|
||||
image: ImageName.NO_INTERNET,
|
||||
};
|
||||
default:
|
||||
return {
|
||||
title: ERROR_TITLE,
|
||||
subtitle: ERROR_SUBTITLE,
|
||||
image: ImageName.SWW,
|
||||
};
|
||||
switch (axiosCode) {
|
||||
case AXIOS_CODE_NETWORK:
|
||||
case AXIOS_CODE_CANCELED:
|
||||
return {
|
||||
title: ERROR_INTERNET_TITLE,
|
||||
subtitle: ERROR_INTERNET_SUBTITLE,
|
||||
image: ImageName.NO_INTERNET,
|
||||
};
|
||||
default:
|
||||
return {
|
||||
title: ERROR_TITLE,
|
||||
subtitle: ERROR_SUBTITLE,
|
||||
image: ImageName.SWW,
|
||||
};
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
@@ -313,7 +313,7 @@ export const handleErrorData = (
|
||||
moduleName: AnalyticsModuleNameConstant.GI,
|
||||
flowName: flowName,
|
||||
methodName: methodName,
|
||||
globalErrorType: getErrorTypeFromStatusCode(error.statusCode || -1),
|
||||
globalErrorType: getErrorTypeFromStatusCode(error.statusCode),
|
||||
isAppDowntimeEvent: false,
|
||||
isNae: false,
|
||||
apiUrl: apiUrl,
|
||||
|
||||
Reference in New Issue
Block a user