Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: show correct error message for interval server errors #6873

Merged
merged 4 commits into from
Dec 20, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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;
}
rithviknishad marked this conversation as resolved.
Show resolved Hide resolved

Expand Down
Loading