when storing settings and something is wrong, show the correct error

This commit is contained in:
orangecoding
2026-06-13 13:33:49 +02:00
parent e82db5b6db
commit 730cc52187

View File

@@ -255,11 +255,11 @@ const GeneralSettings = function GeneralSettings() {
}); });
} catch (exception) { } catch (exception) {
console.error(exception); console.error(exception);
if (exception?.json?.message != null) { // The backend returns the concrete reason in `json.error` (e.g. a 403
Toast.error(exception.json.message); // "Only admins can change these settings."). Fall back to `json.message`
} else { // and finally the generic toast so the user always sees why it failed.
Toast.error(t('settings.toastSaveError')); const serverReason = exception?.json?.error ?? exception?.json?.message;
} Toast.error(serverReason ?? t('settings.toastSaveError'));
return; return;
} }
Toast.success(t('settings.toastSavedReloading')); Toast.success(t('settings.toastSavedReloading'));