A bit of error handling I guess

This commit is contained in:
Tiago Ribeiro
2024-09-08 18:54:44 +01:00
parent d5769c2cb9
commit 49e8237e99
2 changed files with 7 additions and 1 deletions

View File

@@ -141,7 +141,11 @@ export default function UserCreator({user, users, permissions, onFinish}: Props)
setType("student");
setPosition(undefined);
})
.catch(() => toast.error("Something went wrong! Please try again later!"))
.catch((error) => {
const data = error?.response?.data;
if (!!data?.message) return toast.error(data.message);
toast.error("Something went wrong! Please try again later!");
})
.finally(() => setIsLoading(false));
};