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 a314b91
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
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 a314b91

Please sign in to comment.