fix typing errors

This commit is contained in:
Snazzah 2021-08-31 15:37:34 +00:00 committed by GitHub
parent 4bdc29c9d6
commit 3ad20d6e96

View file

@ -23,6 +23,7 @@ import Checkbox from "../../../components/ui/Checkbox";
import InputBox from "../../../components/ui/InputBox"; import InputBox from "../../../components/ui/InputBox";
import Tip from "../../../components/ui/Tip"; import Tip from "../../../components/ui/Tip";
import CategoryButton from "../../../components/ui/fluent/CategoryButton"; import CategoryButton from "../../../components/ui/fluent/CategoryButton";
import type { AxiosError } from "axios";
interface Data { interface Data {
_id: string; _id: string;
@ -92,16 +93,17 @@ function BotCard({ bot, onDelete, onUpdate }: Props) {
onUpdate(changes); onUpdate(changes);
setEditMode(false); setEditMode(false);
} catch (e) { } catch (e) {
if (e.isAxiosError && e.response.data?.type) { const err = e as AxiosError;
switch (e.response.data.type) { if (err.isAxiosError && err.response?.data?.type) {
switch (err.response.data.type) {
case "UsernameTaken": case "UsernameTaken":
setError("That username is taken!"); setError("That username is taken!");
break; break;
default: default:
setError(`Error: ${e.response.data.type}`); setError(`Error: ${err.response.data.type}`);
break; break;
} }
} else setError(e.toString()); } else setError(err.toString());
} }
setSaving(false); setSaving(false);
} }