Skip to content

Commit

Permalink
feat: show correct error message for interval server errors
Browse files Browse the repository at this point in the history
  • Loading branch information
jainvedant392 committed Dec 15, 2023
1 parent 1f5ea20 commit b5b902f
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 28 deletions.
30 changes: 3 additions & 27 deletions src/Redux/fireRequest.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ export const fireRequest = (
}

// 4xx Errors
if (error.response.status > 400 && error.response.status < 500) {
if (error.response.status > 400 && error.response.status < 600) {
if (error.response.data && error.response.data.detail) {
if (error.response.data.code === "token_not_valid") {
window.location.href = `/session-expired?redirect=${window.location.href}`;
Expand All @@ -167,14 +167,6 @@ export const fireRequest = (
}
return;
}

// 5xx Errors
if (error.response.status >= 500 && error.response.status <= 599) {
Notification.Error({
msg: "Something went wrong...!",
});
return;
}
} else {
return error.response;
}
Expand Down Expand Up @@ -264,7 +256,7 @@ export const fireRequestV2 = (
}

// 4xx Errors
if (error.response.status > 400 && error.response.status < 500) {
if (error.response.status > 400 && error.response.status < 600) {
if (error.response.data && error.response.data.detail) {
Notification.Error({
msg: error.response.data.detail,
Expand All @@ -279,14 +271,6 @@ export const fireRequestV2 = (
}
return;
}

// 5xx Errors
if (error.response.status >= 500 && error.response.status <= 599) {
Notification.Error({
msg: "Something went wrong...!",
});
return;
}
}
});
};
Expand Down Expand Up @@ -374,7 +358,7 @@ export const fireRequestForFiles = (
}

// 4xx Errors
if (error.response.status > 400 && error.response.status < 500) {
if (error.response.status > 400 && error.response.status < 600) {
if (error.response.status === 429) {
return error.response;
} else if (error.response.data && error.response.data.detail) {
Expand All @@ -388,14 +372,6 @@ export const fireRequestForFiles = (
}
return;
}

// 5xx Errors
if (error.response.status >= 500 && error.response.status <= 599) {
Notification.Error({
msg: "Something went wrong...!",
});
return;
}
}
});
};
Expand Down
2 changes: 1 addition & 1 deletion src/Utils/request/handleResponse.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export default function handleResponse(
// 5xx errors
if (res.status >= 500 && res.status < 600) {
console.error("Server error", res);
notify?.Error({ msg: "Something went wrong...!" });
notify?.Error({ msg: error?.detail || "Something went wrong...!" });
return;
}

Expand Down

0 comments on commit b5b902f

Please sign in to comment.