From a314b918c1203670904ea81e28c1bf6f286f74da Mon Sep 17 00:00:00 2001 From: Aadesh-Baral Date: Wed, 30 Aug 2023 11:10:40 +0545 Subject: [PATCH] Handle new error response format on frontend. ----------------------- 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. --- frontend/src/utils/promise.js | 2 +- frontend/src/views/project.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/frontend/src/utils/promise.js b/frontend/src/utils/promise.js index a9af63507a..2ee009b416 100644 --- a/frontend/src/utils/promise.js +++ b/frontend/src/utils/promise.js @@ -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); } diff --git a/frontend/src/views/project.js b/frontend/src/views/project.js index 321bbd8826..ac80dd3fb8 100644 --- a/frontend/src/views/project.js +++ b/frontend/src/views/project.js @@ -198,7 +198,7 @@ export const ProjectDetailPage = () => { )} {error && ( <> - {error.message === 'PrivateProject' ? ( + {error.message === 'PRIVATE_PROJECT_NOT_ALLOWED' ? ( ) : (