Skip to content

Commit

Permalink
Handle new error response format on frontend.
Browse files Browse the repository at this point in the history
-----------------------
After the introduction of new exception classes on backend the error response format is changed. As in new error response error subcode should be accessed on error.sub_code this commit handles this case.
Also change in subcode to identify project is private and cannot be accessed by user has been addressed.
  • Loading branch information
Aadesh-Baral committed Aug 30, 2023
1 parent 992c1dd commit a7d9034
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion frontend/src/network/tests/server-handlers.js
Original file line number Diff line number Diff line change
Expand Up @@ -372,7 +372,7 @@ const faultyHandlers = [
return res.once(
ctx.status(403),
ctx.json({
SubCode: `PrivateProject`,
error:{sub_code: `PRIVATE_PROJECT_NOT_ALLOWED`}
}),
);
}),
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/utils/promise.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ export async function handleErrors(response) {
.clone()
.json()
.then((res) => {
text = res.SubCode || response.statusText;
text = res.error?.sub_code || res.SubCode || response.statusText;
});
throw Error(text);
}
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/views/project.js
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ export const ProjectDetailPage = () => {
)}
{error && (
<>
{error.message === 'PrivateProject' ? (
{error.message === 'PRIVATE_PROJECT_NOT_ALLOWED' ? (
<PrivateProjectError />
) : (
<NotFound projectId={id} />
Expand Down

0 comments on commit a7d9034

Please sign in to comment.