Catch Blocks

This commit is contained in:
PxlLoewe
2026-02-01 00:01:06 +01:00
parent 829d6d8cde
commit a60cd67c44
5 changed files with 92 additions and 65 deletions

View File

@@ -663,10 +663,15 @@ export const AdminForm = ({
>
<Button
onClick={async () => {
await setStandardName({
const res = (await setStandardName({
memberId: discordAccount.discordId,
userId: user.id,
});
})) as unknown as { error?: string };
console.log(res);
if (res?.error) {
toast.error(res.error);
return;
}
toast.success("Standard Name wurde gesetzt!", {
style: {
background: "var(--color-base-100)",

View File

@@ -1,5 +1,5 @@
"use server";
import axios from "axios";
import axios, { AxiosError } from "axios";
const discordAxiosClient = axios.create({
baseURL: process.env.CORE_SERVER_URL || "http://localhost:3005",
@@ -55,12 +55,17 @@ export const setStandardName = async ({
memberId: string;
userId: string;
}) => {
discordAxiosClient
return discordAxiosClient
.post("/helper/set-standard-name", {
memberId,
userId,
})
.catch((error) => {
console.error("Error removing roles from member:", error);
console.log("Error removing roles from member:", error);
return {
error:
((error as unknown as AxiosError).response?.data as unknown as { error: string }).error ||
(error as unknown as AxiosError).message,
};
});
};