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(); refetch();
onClose(); onClose();
} catch (err) { } catch (err) {
if (err instanceof ApiError) {
const apiError = err as ApiError;
if ( if (
apiError.status === 400 && err instanceof ApiError &&
(apiError.body as any).detail == "Room name is not unique" err.status === 400 &&
(err.body as any).detail == "Room name is not unique"
) { ) {
setNameError( setNameError(
"This room name is already taken. Please choose a different name.", "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."); setNameError("An error occurred. Please try again.");
} }
} }
}
}; };
const handleEditRoom = (roomId, roomData) => { const handleEditRoom = (roomId, roomData) => {