Handle unexpected exceptions better
This commit is contained in:
@ -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!",
|
||||||
|
@ -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());
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user