Added error handling

This commit is contained in:
Lucas Oliveira 2023-11-16 22:29:56 -03:00
commit 598cd04b31

View file

@ -50,13 +50,13 @@ export default function CollectionCardComponent({
const newFlow = cloneFLowWithParent(res, res.id, data.is_component); const newFlow = cloneFLowWithParent(res, res.id, data.is_component);
addFlow(true, newFlow) addFlow(true, newFlow)
.then((id) => { .then((id) => {
setSuccessData({ title: `${name} Installed` }); setSuccessData({ title: `${name} Installed Successfully.` });
setLoading(false); setLoading(false);
}) })
.catch((error) => { .catch((error) => {
setLoading(false); setLoading(false);
setErrorData({ setErrorData({
title: `There was an error installing the ${name}`, title: `Error installing the ${name}`,
list: [error["response"]["data"]["detail"]], list: [error["response"]["data"]["detail"]],
}); });
}); });
@ -84,9 +84,15 @@ export default function CollectionCardComponent({
setLoadingLike(false); setLoadingLike(false);
setLikes_count(tempNum); setLikes_count(tempNum);
setLiked_by_user(temp); setLiked_by_user(temp);
if (error.response.status === 403) {
setValidApiKey(false); setValidApiKey(false);
} else {
console.error(error); console.error(error);
setErrorData({
title: `Error liking ${name}.`,
list: [error["response"]["data"]["detail"]],
});
}
}); });
} }
} }