From 47edbf64b5a83c571df62a71b4c3525fe314abfe Mon Sep 17 00:00:00 2001 From: Luca <102960244+Luca-Timo@users.noreply.github.com> Date: Wed, 3 Jun 2026 19:56:26 +0200 Subject: [PATCH] fix(email): surface the real error on test/save/flush instead of generic toast MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The test-email, save-config, and flush mutations all showed the generic 'Failed to save changes' toast on error, hiding the actual backend reason — so a failing test email looked like a save failure and gave no diagnosis. Show response.data.error / .details (SMTP auth/connection failure, masked password, private-host rejection, …) with the generic string as fallback. --- frontend/src/pages/admin/EmailConfigPage.tsx | 21 ++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/frontend/src/pages/admin/EmailConfigPage.tsx b/frontend/src/pages/admin/EmailConfigPage.tsx index 457e227a..2eadaf24 100644 --- a/frontend/src/pages/admin/EmailConfigPage.tsx +++ b/frontend/src/pages/admin/EmailConfigPage.tsx @@ -228,14 +228,23 @@ export const EmailConfigPage: React.FC = () => { }, [selectedTemplate]); // Mutations + // Surface the actual backend error (SMTP auth/connection failure, masked + // password, private-host rejection, …) instead of a generic toast — for + // email config these messages are the whole diagnosis. + const errMsg = (e: any, fallback: string): string => + e?.response?.data?.error + || e?.response?.data?.details + || e?.message + || fallback; + const saveConfigMutation = useMutation({ mutationFn: (config: EmailConfig) => emailService.updateConfig(config), onSuccess: () => { toast.success(t('toast.emailConfigSaved')); queryClient.invalidateQueries({ queryKey: ['email-config'] }); }, - onError: () => { - toast.error(t('toast.saveError')); + onError: (e: any) => { + toast.error(errMsg(e, t('toast.saveError'))); } }); @@ -244,8 +253,8 @@ export const EmailConfigPage: React.FC = () => { onSuccess: () => { toast.success(t('email.testEmailSuccess')); }, - onError: () => { - toast.error(t('toast.saveError')); + onError: (e: any) => { + toast.error(errMsg(e, t('toast.saveError'))); } }); @@ -258,8 +267,8 @@ export const EmailConfigPage: React.FC = () => { toast.success(t('email.flushQueue.success', { sent: summary.sent, failed: summary.failed })); } }, - onError: () => { - toast.error(t('toast.saveError')); + onError: (e: any) => { + toast.error(errMsg(e, t('toast.saveError'))); } });