Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Handle unexpected exceptions better
  • Loading branch information
regalijan committed Oct 19, 2023
1 parent 8f05c32 commit 8967818
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
9 changes: 8 additions & 1 deletion components/AppealCard.tsx
Expand Up @@ -62,9 +62,16 @@ export default function (props: AppealCardProps) {

document.getElementById(`appeal_${props.id}`)?.remove();
} else {
let error;

try {
error = ((await actionReq.json()) as { error: string }).error;
} catch {
error = "Unknown error";
}
setLoading(false);
toast({
description: ((await actionReq.json()) as { error: string }).error,
description: error,
duration: 10000,
status: "error",
title: "Oops!",
Expand Down
2 changes: 1 addition & 1 deletion functions/gcloud.ts
Expand Up @@ -296,5 +296,5 @@ export async function sendPushNotification(
},
);

if (!notifResp.ok) throw new Error(await notifResp.json());
if (!notifResp.ok) throw new Error(await notifResp.text());
}

0 comments on commit 8967818

Please sign in to comment.