Skip to content

Commit

Permalink
change error logs to show error.message only
Browse files Browse the repository at this point in the history
  • Loading branch information
meetulr committed Mar 24, 2024
1 parent 8b31baa commit 4f36d9c
Show file tree
Hide file tree
Showing 9 changed files with 71 additions and 41 deletions.
16 changes: 10 additions & 6 deletions src/components/ActionItems/ActionItemsContainer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
};

Expand All @@ -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);
}
}
};

Expand Down
8 changes: 5 additions & 3 deletions src/components/ActionItems/ActionItemsModalBody.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
};

Expand Down
24 changes: 15 additions & 9 deletions src/components/OrgActionItemCategories/OrgActionItemCategories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
};

Expand All @@ -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);
}
}
}
};
Expand All @@ -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);
}
}
};

Expand Down
10 changes: 6 additions & 4 deletions src/components/OrgPostCard/OrgPostCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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 => {
Expand Down
2 changes: 1 addition & 1 deletion src/components/UserPortal/UserSidebar/UserSidebar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ function userSidebar(): JSX.Element {
variables: { userId: userId },
});

console.log(error);
console.log(error?.message);

/* istanbul ignore next */
React.useEffect(() => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
};

Expand Down
18 changes: 12 additions & 6 deletions src/screens/OrganizationFundCampaign/OrganizationFundCampagins.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
};

Expand Down Expand Up @@ -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);
}
}
};

Expand All @@ -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) {
Expand Down
24 changes: 16 additions & 8 deletions src/screens/OrganizationFunds/OrganizationFunds.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
Expand Down Expand Up @@ -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<void> => {
Expand All @@ -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<void> => {
Expand All @@ -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
Expand Down
8 changes: 5 additions & 3 deletions src/screens/OrganizationPeople/AddMember.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
};

Expand Down

0 comments on commit 4f36d9c

Please sign in to comment.