Skip to content

Commit

Permalink
chore: fix better messages on milestones error
Browse files Browse the repository at this point in the history
  • Loading branch information
Noggling committed Mar 13, 2024
1 parent 87a19fc commit c62ae01
Showing 1 changed file with 12 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,19 @@ export async function getMilestones(
const res = await client.fetch(`/api/contexts/${contextId}/milestones`, { signal });

if (res.status === 403) throw new Error('No access');

const data = (await res.json()) as Milestones[];

if (res.status === 400 && (data as unknown as { detail: string }).detail.includes('Forbidden')) {
throw new Error('No access');
}

if (res.status === 424 && (data as unknown as { detail: string }).detail.includes('Forbidden')) {
throw new Error('No access');
}

if (!res.ok) throw new Error('Unknown Error');
return (await res.json()) as Milestones[];
return data;
}

export const useMilestoneQuery = () => {
Expand Down

0 comments on commit c62ae01

Please sign in to comment.