Handle unexpected exceptions better

This commit is contained in:
2023-10-19 16:51:17 -04:00
parent 8f05c3294a
commit 8967818fcc
2 changed files with 9 additions and 2 deletions

View File

@ -62,9 +62,16 @@ export default function (props: AppealCardProps) {
document.getElementById(`appeal_${props.id}`)?.remove(); document.getElementById(`appeal_${props.id}`)?.remove();
} else { } else {
let error;
try {
error = ((await actionReq.json()) as { error: string }).error;
} catch {
error = "Unknown error";
}
setLoading(false); setLoading(false);
toast({ toast({
description: ((await actionReq.json()) as { error: string }).error, description: error,
duration: 10000, duration: 10000,
status: "error", status: "error",
title: "Oops!", title: "Oops!",

View File

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