Skip to content

Commit

Permalink
Custom error message for non-existing resource
Browse files Browse the repository at this point in the history
  • Loading branch information
garciafdezpatricia committed Jun 28, 2024
1 parent b476c19 commit 53bcb59
Showing 1 changed file with 12 additions and 7 deletions.
19 changes: 12 additions & 7 deletions pages/approve.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -95,11 +95,17 @@ function Approval({
.catch((error) => setErr(error));
}, [accessRequest, sessionFetch, getNameFromWebId]);

useEffect(fetchAccessRequest, [fetchAccessRequest]);
const checkErrorForNonExistingResource = (approveDenyError: any) => {
if (approveDenyError.response && approveDenyError.response.status === 404) {
return "Error: Granting access to a non-existing resource is not supported in Legacy pods.";
}
if ("message" in approveDenyError) {
return `${approveDenyError}`;
}
return `${approveDenyError.message}`;
};

useEffect(() => {
console.log(updateAcr);
}, [updateAcr]);
useEffect(fetchAccessRequest, [fetchAccessRequest]);

return (
<>
Expand Down Expand Up @@ -216,9 +222,8 @@ function Approval({
<br />
<br />
<code>
{approveDenyError && "message" in approveDenyError
? `${approveDenyError}`
: `${approveDenyError.message}`}
{approveDenyError &&
`${checkErrorForNonExistingResource(approveDenyError)}`}
</code>
</Modal>
{request && (
Expand Down

0 comments on commit 53bcb59

Please sign in to comment.