mirror of
https://github.com/Monadical-SAS/reflector.git
synced 2025-12-20 12:19:06 +00:00
Fix api error handling
This commit is contained in:
@@ -179,18 +179,16 @@ export default function RoomsList() {
|
|||||||
refetch();
|
refetch();
|
||||||
onClose();
|
onClose();
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
if (err instanceof ApiError) {
|
if (
|
||||||
const apiError = err as ApiError;
|
err instanceof ApiError &&
|
||||||
if (
|
err.status === 400 &&
|
||||||
apiError.status === 400 &&
|
(err.body as any).detail == "Room name is not unique"
|
||||||
(apiError.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.",
|
);
|
||||||
);
|
} else {
|
||||||
} else {
|
setNameError("An error occurred. Please try again.");
|
||||||
setNameError("An error occurred. Please try again.");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user