From a6ecf379b31f3b98263cd126cf3963588af4834a Mon Sep 17 00:00:00 2001 From: garciafdezpatricia Date: Thu, 27 Jun 2024 13:24:49 +0200 Subject: [PATCH] Custom error message for non-existing resources --- pages/approve.tsx | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/pages/approve.tsx b/pages/approve.tsx index 3a2c757..ed0afe6 100644 --- a/pages/approve.tsx +++ b/pages/approve.tsx @@ -95,6 +95,16 @@ function Approval({ .catch((error) => setErr(error)); }, [accessRequest, sessionFetch, getNameFromWebId]); + 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(fetchAccessRequest, [fetchAccessRequest]); return ( @@ -212,9 +222,8 @@ function Approval({

- {approveDenyError && "message" in approveDenyError - ? `${approveDenyError}` - : `${approveDenyError.message}`} + {approveDenyError && + `${checkErrorForNonExistingResource(approveDenyError)}`} {request && (