Skip to content

Commit

Permalink
Fix: Added trycatch() to handleWeeklyPickChange(), added a throw erro…
Browse files Browse the repository at this point in the history
…r inside onWeeklyPickChange(), and updated IData to IWeekData
  • Loading branch information
alexappleget committed Jul 26, 2024
1 parent baa8836 commit 4933a40
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import {
IUser,
} from '@/api/apiFunctions.interface';

export interface IData {
export interface IWeekData {
target: {
value: string;
};
Expand All @@ -24,7 +24,7 @@ export interface IWeekParams {
}

export interface IWeeklyPickChange {
data: IData;
data: IWeekData;
entry: string;
league: string;
NFLTeams: INFLTeam[];
Expand Down
6 changes: 5 additions & 1 deletion app/(main)/league/[leagueId]/entry/[entryId]/week/Week.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,11 @@ const Week = ({ entry, league, NFLTeams, week }: IWeekProps): JSX.Element => {
weeklyPicks,
week,
};
await onWeeklyPickChange(params);
try {
await onWeeklyPickChange(params);
} catch (error) {
console.error('Error while changing pick:', error);
}
};

useEffect(() => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,12 +80,12 @@ export const onWeeklyPickChange = async ({
/>,
);
} catch (error) {
console.error('Submission error:', error);
toast.custom(
<Alert
variant={AlertVariants.Error}
message="There was an error processing your request."
/>,
);
throw new Error(`Error running onWeeklyPickChange: ${error}`);
}
};

0 comments on commit 4933a40

Please sign in to comment.