From f7bfcb0da58e6735fd2a59d11e27d3192a5cc492 Mon Sep 17 00:00:00 2001 From: meetul Date: Sun, 24 Mar 2024 13:11:48 +0530 Subject: [PATCH] change error log to error.message --- .../AdvertisementRegister.tsx | 15 ++++++++++----- .../OrganizationActionItems.tsx | 8 +++++--- .../OrganizationDashboard.tsx | 2 +- 3 files changed, 16 insertions(+), 9 deletions(-) diff --git a/src/components/Advertisements/core/AdvertisementRegister/AdvertisementRegister.tsx b/src/components/Advertisements/core/AdvertisementRegister/AdvertisementRegister.tsx index 44216c8761..d9ad01e258 100644 --- a/src/components/Advertisements/core/AdvertisementRegister/AdvertisementRegister.tsx +++ b/src/components/Advertisements/core/AdvertisementRegister/AdvertisementRegister.tsx @@ -117,9 +117,11 @@ function advertisementRegister({ }); handleClose(); } - } catch (error) { - toast.error('An error occured, could not create new advertisement'); - console.log('error occured', error); + } catch (error: unknown) { + if (error instanceof Error) { + toast.error(error.message); + console.log(error.message); + } } }; const handleUpdate = async (): Promise => { @@ -181,8 +183,11 @@ function advertisementRegister({ refetch(); handleClose(); } - } catch (error: any) { - toast.error(error.message); + } catch (error: unknown) { + if (error instanceof Error) { + toast.error(error.message); + console.log(error.message); + } } }; return ( diff --git a/src/screens/OrganizationActionItems/OrganizationActionItems.tsx b/src/screens/OrganizationActionItems/OrganizationActionItems.tsx index 2fdb63a93c..3c5a083e32 100644 --- a/src/screens/OrganizationActionItems/OrganizationActionItems.tsx +++ b/src/screens/OrganizationActionItems/OrganizationActionItems.tsx @@ -123,9 +123,11 @@ function organizationActionItems(): JSX.Element { actionItemsRefetch(); hideCreateModal(); toast.success(t('successfulCreation')); - } catch (error: any) { - toast.error(error.message); - console.log(error.message); + } catch (error: unknown) { + if (error instanceof Error) { + toast.error(error.message); + console.log(error.message); + } } }; diff --git a/src/screens/OrganizationDashboard/OrganizationDashboard.tsx b/src/screens/OrganizationDashboard/OrganizationDashboard.tsx index 628d104276..e6f6f5bd9c 100644 --- a/src/screens/OrganizationDashboard/OrganizationDashboard.tsx +++ b/src/screens/OrganizationDashboard/OrganizationDashboard.tsx @@ -103,7 +103,7 @@ function organizationDashboard(): JSX.Element { useEffect(() => { if (errorOrg || errorPost || errorEvent) { - console.log('error', errorPost); + console.log('error', errorPost?.message); navigate('/orglist'); } }, [errorOrg, errorPost, errorEvent]);