Skip to content

Commit 849a807

Browse files
committed
#1250: Added try/catch back to CheckList and ProposedSolutionsList
1 parent 68cd6c9 commit 849a807

2 files changed

Lines changed: 10 additions & 2 deletions

File tree

src/frontend/src/components/CheckList.tsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import { Tooltip } from '@mui/material';
1414
import { User } from 'shared';
1515
import NERModal from './NERModal';
1616
import { fullNamePipe } from '../utils/pipes';
17+
import { useToast } from '../hooks/toasts.hooks';
1718

1819
export type CheckListItem = {
1920
id: number;
@@ -34,6 +35,7 @@ const CheckList: React.FC<CheckListProps> = ({ title, items, isDisabled }) => {
3435
const { isLoading, mutateAsync } = useCheckDescriptionBullet();
3536
const [showConfirm, setShowConfirm] = useState<boolean>(false);
3637
const [currIdx, setCurrIdx] = useState<number>(-1);
38+
const toast = useToast();
3739

3840
const handleUncheck = async (idx: number) => {
3941
await handleCheck(idx);
@@ -44,7 +46,9 @@ const CheckList: React.FC<CheckListProps> = ({ title, items, isDisabled }) => {
4446
try {
4547
await mutateAsync({ userId: auth.user!.userId, descriptionId: items[idx].id });
4648
} catch (e) {
47-
// do nothing; toasting error message will cause errors
49+
if (e instanceof Error) {
50+
toast.error(e.message);
51+
}
4852
}
4953
};
5054

src/frontend/src/pages/ChangeRequestDetailPage/ProposedSolutionsList.tsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import ErrorPage from '../ErrorPage';
1313
import LoadingIndicator from '../../components/LoadingIndicator';
1414
import { useAuth } from '../../hooks/auth.hooks';
1515
import { Button } from '@mui/material';
16+
import { useToast } from '../../hooks/toasts.hooks';
1617

1718
interface ProposedSolutionsListProps {
1819
proposedSolutions: ProposedSolution[];
@@ -24,6 +25,7 @@ const ProposedSolutionsList: React.FC<ProposedSolutionsListProps> = ({ proposedS
2425
const [showEditableForm, setShowEditableForm] = useState<boolean>(false);
2526
const auth = useAuth();
2627
const { isLoading, isError, error, mutateAsync } = useCreateProposeSolution();
28+
const toast = useToast();
2729

2830
if (isLoading || !auth.user) return <LoadingIndicator />;
2931
if (isError) return <ErrorPage message={error?.message} />;
@@ -44,7 +46,9 @@ const ProposedSolutionsList: React.FC<ProposedSolutionsListProps> = ({ proposedS
4446
budgetImpact
4547
});
4648
} catch (e) {
47-
// do nothing; toasting error message will cause errors
49+
if (e instanceof Error) {
50+
toast.error(e.message);
51+
}
4852
}
4953
};
5054

0 commit comments

Comments
 (0)