From 0f4035b6615ffa923b60fa7462833c38338c156b Mon Sep 17 00:00:00 2001 From: Calum Muir Date: Mon, 22 Dec 2025 12:54:18 +0000 Subject: [PATCH] Improve contact form error reporting --- client/src/pages/Contact.tsx | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/client/src/pages/Contact.tsx b/client/src/pages/Contact.tsx index bfdedc1..0314e19 100644 --- a/client/src/pages/Contact.tsx +++ b/client/src/pages/Contact.tsx @@ -64,8 +64,16 @@ export const Contact = (): JSX.Element => { if (!response.ok) { const errorData = (await response.json().catch(() => null)) as { error?: string; + details?: string; } | null; - throw new Error(errorData?.error ?? "Request failed"); + if (errorData?.error) { + throw new Error(errorData.error); + } + const errorText = await response.text().catch(() => ""); + const message = errorText.trim() + ? `${response.status} ${response.statusText}: ${errorText}` + : `${response.status} ${response.statusText}`; + throw new Error(message || "Request failed"); } setFormStatus("success"); setFormMessage("Thanks! Your message has been sent.");