From 598cd04b318986dee43fb9a90517318b91cedebf Mon Sep 17 00:00:00 2001 From: Lucas Oliveira Date: Thu, 16 Nov 2023 22:29:56 -0300 Subject: [PATCH] Added error handling --- .../src/components/cardComponent/index.tsx | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/src/frontend/src/components/cardComponent/index.tsx b/src/frontend/src/components/cardComponent/index.tsx index 1f36361e3..6876665d3 100644 --- a/src/frontend/src/components/cardComponent/index.tsx +++ b/src/frontend/src/components/cardComponent/index.tsx @@ -50,13 +50,13 @@ export default function CollectionCardComponent({ const newFlow = cloneFLowWithParent(res, res.id, data.is_component); addFlow(true, newFlow) .then((id) => { - setSuccessData({ title: `${name} Installed` }); + setSuccessData({ title: `${name} Installed Successfully.` }); setLoading(false); }) .catch((error) => { setLoading(false); setErrorData({ - title: `There was an error installing the ${name}`, + title: `Error installing the ${name}`, list: [error["response"]["data"]["detail"]], }); }); @@ -84,9 +84,15 @@ export default function CollectionCardComponent({ setLoadingLike(false); setLikes_count(tempNum); setLiked_by_user(temp); - - setValidApiKey(false); - console.error(error); + if (error.response.status === 403) { + setValidApiKey(false); + } else { + console.error(error); + setErrorData({ + title: `Error liking ${name}.`, + list: [error["response"]["data"]["detail"]], + }); + } }); } }