From a88349f8d35ea2b94f414eb4ffda2bef3af32044 Mon Sep 17 00:00:00 2001 From: SHestres Date: Tue, 17 Dec 2024 07:22:36 +0000 Subject: [PATCH] Pass api error message through to toast notification when editing a user Any errors returned by the API when submitting edits to a user caused the loading spinner to stay on screen. This hides the spinner and makes the error message visible to the user --- src/apps/dashboard/routes/users/profile.tsx | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/apps/dashboard/routes/users/profile.tsx b/src/apps/dashboard/routes/users/profile.tsx index fa4b077845..f9f6c9a4a1 100644 --- a/src/apps/dashboard/routes/users/profile.tsx +++ b/src/apps/dashboard/routes/users/profile.tsx @@ -230,7 +230,16 @@ const UserEdit = () => { )).then(() => { onSaveComplete(); }).catch(err => { - console.error('[useredit] failed to update user', err); + try { + console.error('[useredit] failed to update user', err); + err.text().then((errorMessage: string) => { + toast(errorMessage); + loading.hide(); + }); + } catch { + toast(globalize.translate('ErrorDefault')); + loading.hide(); + } }); };