improved error handling

This commit is contained in:
2025-09-30 12:59:38 +02:00
parent 9cad1e8b6b
commit 8f9696991f
2 changed files with 13 additions and 1 deletions

View File

@@ -59,6 +59,14 @@ const AddAPIKey: React.FC<AddAPIKeyProps> = ({ onClose, alert }) => {
"Der API Key wurde erfolgreich erstellt." "Der API Key wurde erfolgreich erstellt."
); );
onClose(); onClose();
} else {
alert(
"error",
"Fehler beim Erstellen des API Keys",
res.message ||
"Beim Erstellen des API Keys ist ein Fehler aufgetreten. (frontend bug)"
);
onClose();
} }
}} }}
> >

View File

@@ -213,7 +213,11 @@ export const createAPIentry = async (apiKey: string, user: string) => {
body: JSON.stringify({ apiKey, user }), body: JSON.stringify({ apiKey, user }),
}); });
if (!response.ok) { if (!response.ok) {
throw new Error("Failed to create API entry"); return {
success: false,
message:
"Fehler beim Erstellen des API Keys. Achten Sie darauf, dass alle Felder ausgefüllt sind und der API Key nicht doppelt vergeben wird.",
};
} }
return { success: true }; return { success: true };
} catch (error) { } catch (error) {