Fix api error handling

This commit is contained in:
2024-09-25 13:30:58 +02:00
parent 83857507ea
commit 3ba3192800

View File

@@ -179,11 +179,10 @@ export default function RoomsList() {
refetch();
onClose();
} catch (err) {
if (err instanceof ApiError) {
const apiError = err as ApiError;
if (
apiError.status === 400 &&
(apiError.body as any).detail == "Room name is not unique"
err instanceof ApiError &&
err.status === 400 &&
(err.body as any).detail == "Room name is not unique"
) {
setNameError(
"This room name is already taken. Please choose a different name.",
@@ -192,7 +191,6 @@ export default function RoomsList() {
setNameError("An error occurred. Please try again.");
}
}
}
};
const handleEditRoom = (roomId, roomData) => {