diff --git a/src/components/ActionItems/ActionItemsContainer.tsx b/src/components/ActionItems/ActionItemsContainer.tsx index 80a5d9651e..fef8d3bfda 100644 --- a/src/components/ActionItems/ActionItemsContainer.tsx +++ b/src/components/ActionItems/ActionItemsContainer.tsx @@ -111,9 +111,11 @@ function actionItemsContainer({ actionItemsRefetch(); hideUpdateModal(); toast.success(t('successfulUpdation')); - } catch (error: any) { - toast.error(error.message); - console.log(error); + } catch (error: unknown) { + if (error instanceof Error) { + toast.error(error.message); + console.log(error.message); + } } }; @@ -129,9 +131,11 @@ function actionItemsContainer({ actionItemsRefetch(); toggleDeleteModal(); toast.success(t('successfulDeletion')); - } catch (error: any) { - toast.error(error.message); - console.log(error); + } catch (error: unknown) { + if (error instanceof Error) { + toast.error(error.message); + console.log(error.message); + } } }; diff --git a/src/components/ActionItems/ActionItemsModalBody.tsx b/src/components/ActionItems/ActionItemsModalBody.tsx index e7c505a9a4..59de3b1681 100644 --- a/src/components/ActionItems/ActionItemsModalBody.tsx +++ b/src/components/ActionItems/ActionItemsModalBody.tsx @@ -118,9 +118,11 @@ export const ActionItemsModalBody = ({ actionItemsRefetch(); hideCreateModal(); toast.success(t('successfulCreation')); - } catch (error: any) { - toast.error(error.message); - console.log(error); + } catch (error: unknown) { + if (error instanceof Error) { + toast.error(error.message); + console.log(error.message); + } } }; diff --git a/src/components/OrgActionItemCategories/OrgActionItemCategories.tsx b/src/components/OrgActionItemCategories/OrgActionItemCategories.tsx index 2148255909..5f4c356af6 100644 --- a/src/components/OrgActionItemCategories/OrgActionItemCategories.tsx +++ b/src/components/OrgActionItemCategories/OrgActionItemCategories.tsx @@ -75,9 +75,11 @@ const OrgActionItemCategories = (): any => { setModalIsOpen(false); toast.success(t('successfulCreation')); - } catch (error: any) { - toast.error(error.message); - console.log(error); + } catch (error: unknown) { + if (error instanceof Error) { + toast.error(error.message); + console.log(error.message); + } } }; @@ -101,9 +103,11 @@ const OrgActionItemCategories = (): any => { setModalIsOpen(false); toast.success(t('successfulUpdation')); - } catch (error: any) { - toast.error(error.message); - console.log(error); + } catch (error: unknown) { + if (error instanceof Error) { + toast.error(error.message); + console.log(error.message); + } } } }; @@ -125,9 +129,11 @@ const OrgActionItemCategories = (): any => { toast.success( disabledStatus ? t('categoryEnabled') : t('categoryDisabled'), ); - } catch (error: any) { - toast.error(error.message); - console.log(error); + } catch (error: unknown) { + if (error instanceof Error) { + toast.error(error.message); + console.log(error.message); + } } }; diff --git a/src/components/OrgPostCard/OrgPostCard.tsx b/src/components/OrgPostCard/OrgPostCard.tsx index a40b59979f..17fa9fb94a 100644 --- a/src/components/OrgPostCard/OrgPostCard.tsx +++ b/src/components/OrgPostCard/OrgPostCard.tsx @@ -68,10 +68,12 @@ export default function orgPostCard( window.location.reload(); }, 2000); } - } catch (error: any) { - console.log(error); - /* istanbul ignore next */ - errorHandler(t, error); + } catch (error: unknown) { + if (error instanceof Error) { + console.log(error.message); + /* istanbul ignore next */ + errorHandler(t, error); + } } }; const toggleShowEditModal = (): void => { diff --git a/src/components/UserPortal/UserSidebar/UserSidebar.tsx b/src/components/UserPortal/UserSidebar/UserSidebar.tsx index 79a5e1fada..997b0bfbc6 100644 --- a/src/components/UserPortal/UserSidebar/UserSidebar.tsx +++ b/src/components/UserPortal/UserSidebar/UserSidebar.tsx @@ -40,7 +40,7 @@ function userSidebar(): JSX.Element { variables: { userId: userId }, }); - console.log(error); + console.log(error?.message); /* istanbul ignore next */ React.useEffect(() => { diff --git a/src/screens/OrganizationActionItems/OrganizationActionItems.tsx b/src/screens/OrganizationActionItems/OrganizationActionItems.tsx index ebc7ab8e91..2fdb63a93c 100644 --- a/src/screens/OrganizationActionItems/OrganizationActionItems.tsx +++ b/src/screens/OrganizationActionItems/OrganizationActionItems.tsx @@ -125,7 +125,7 @@ function organizationActionItems(): JSX.Element { toast.success(t('successfulCreation')); } catch (error: any) { toast.error(error.message); - console.log(error); + console.log(error.message); } }; diff --git a/src/screens/OrganizationFundCampaign/OrganizationFundCampagins.tsx b/src/screens/OrganizationFundCampaign/OrganizationFundCampagins.tsx index 772d814586..3775a91d42 100644 --- a/src/screens/OrganizationFundCampaign/OrganizationFundCampagins.tsx +++ b/src/screens/OrganizationFundCampaign/OrganizationFundCampagins.tsx @@ -125,8 +125,10 @@ const orgFundCampaign = (): JSX.Element => { refetchFundCampaign(); hideCreateCampaignModal(); } catch (error: unknown) { - toast.error((error as Error).message); - console.log(error); + if (error instanceof Error) { + toast.error(error.message); + console.log(error.message); + } } }; @@ -172,8 +174,10 @@ const orgFundCampaign = (): JSX.Element => { hideUpdateCampaignModal(); toast.success(t('updatedCampaign')); } catch (error: unknown) { - toast.error((error as Error).message); - console.log(error); + if (error instanceof Error) { + toast.error(error.message); + console.log(error.message); + } } }; @@ -188,8 +192,10 @@ const orgFundCampaign = (): JSX.Element => { refetchFundCampaign(); hideDeleteCampaignModal(); } catch (error: unknown) { - toast.error((error as Error).message); - console.log(error); + if (error instanceof Error) { + toast.error(error.message); + console.log(error.message); + } } }; if (fundCampaignLoading) { diff --git a/src/screens/OrganizationFunds/OrganizationFunds.tsx b/src/screens/OrganizationFunds/OrganizationFunds.tsx index 625e79d54b..7cd22eef82 100644 --- a/src/screens/OrganizationFunds/OrganizationFunds.tsx +++ b/src/screens/OrganizationFunds/OrganizationFunds.tsx @@ -130,8 +130,10 @@ const organizationFunds = (): JSX.Element => { refetchFunds(); hideCreateModal(); } catch (error: unknown) { - toast.error((error as Error).message); - console.log(error); + if (error instanceof Error) { + toast.error(error.message); + console.log(error.message); + } } }; const updateFundHandler = async ( @@ -167,8 +169,10 @@ const organizationFunds = (): JSX.Element => { hideUpdateModal(); toast.success(t('fundUpdated')); } catch (error: unknown) { - toast.error((error as Error).message); - console.log(error); + if (error instanceof Error) { + toast.error(error.message); + console.log(error.message); + } } }; const archiveFundHandler = async (): Promise => { @@ -185,8 +189,10 @@ const organizationFunds = (): JSX.Element => { ? toast.success(t('fundUnarchived')) : toast.success(t('fundArchived')); } catch (error: unknown) { - toast.error((error as Error).message); - console.log(error); + if (error instanceof Error) { + toast.error(error.message); + console.log(error.message); + } } }; const deleteFundHandler = async (): Promise => { @@ -200,8 +206,10 @@ const organizationFunds = (): JSX.Element => { toggleDeleteModal(); toast.success(t('fundDeleted')); } catch (error: unknown) { - toast.error((error as Error).message); - console.log(error); + if (error instanceof Error) { + toast.error(error.message); + console.log(error.message); + } } }; //it is used to rerender the component to use updated Fund in setState diff --git a/src/screens/OrganizationPeople/AddMember.tsx b/src/screens/OrganizationPeople/AddMember.tsx index 2ec02cf7aa..abe81fc451 100644 --- a/src/screens/OrganizationPeople/AddMember.tsx +++ b/src/screens/OrganizationPeople/AddMember.tsx @@ -87,9 +87,11 @@ function AddMember(): JSX.Element { memberRefetch({ orgId: currentUrl, }); - } catch (error: any) { - toast.error(error.message); - console.log(error); + } catch (error: unknown) { + if (error instanceof Error) { + toast.error(error.message); + console.log(error.message); + } } };