Skip to content

📈 Open source, privacy-first web analytics — a cookie-less Google Analytics alternative with built-in error tracking and performance monitoring. Self-host it or use our cloud. Get started for free!

fix: display backend errors in toast properly

Blue Mouse88137169ff6e
diff --git a/web/app/pages/Organisations/Organisations.tsx b/web/app/pages/Organisations/Organisations.tsx
index b67f98942..578541986 100644
--- a/web/app/pages/Organisations/Organisations.tsx
+++ b/web/app/pages/Organisations/Organisations.tsx
@@ -78,7 +78,7 @@ const Organisations = () => {
closeNewOrganisationModal()
} catch (reason: any) {
setNewOrganisationError(reason)
- toast.error(t('apiNotifications.organisationCreateError'))
+ toast.error(typeof reason === 'string' ? reason : t('apiNotifications.organisationCreateError'))
} finally {
setIsNewOrganisationLoading(false)
}
diff --git a/web/app/pages/Project/tabs/Errors/ErrorsView.tsx b/web/app/pages/Project/tabs/Errors/ErrorsView.tsx
index f13a8eb64..17dc74465 100644
--- a/web/app/pages/Project/tabs/Errors/ErrorsView.tsx
+++ b/web/app/pages/Project/tabs/Errors/ErrorsView.tsx
@@ -582,7 +582,7 @@ const ErrorsView = () => {
updateStatusInErrors('resolved')
} catch (reason) {
console.error('[markErrorAsResolved]', reason)
- toast.error(t('apiNotifications.updateErrorStatusFailed'))
+ toast.error(typeof reason === 'string' ? reason : t('apiNotifications.updateErrorStatusFailed'))
setErrorStatusUpdating(false)
return
}
@@ -602,7 +602,7 @@ const ErrorsView = () => {
updateStatusInErrors('active')
} catch (reason) {
console.error('[markErrorAsActive]', reason)
- toast.error(t('apiNotifications.updateErrorStatusFailed'))
+ toast.error(typeof reason === 'string' ? reason : t('apiNotifications.updateErrorStatusFailed'))
setErrorStatusUpdating(false)
return
}
diff --git a/web/app/pages/Project/tabs/Experiments/ExperimentSettingsModal.tsx b/web/app/pages/Project/tabs/Experiments/ExperimentSettingsModal.tsx
index 0177bfd97..8b0d0bc04 100644
--- a/web/app/pages/Project/tabs/Experiments/ExperimentSettingsModal.tsx
+++ b/web/app/pages/Project/tabs/Experiments/ExperimentSettingsModal.tsx
@@ -126,7 +126,7 @@ const ExperimentSettingsModal = ({
}
} catch (error) {
console.error('Failed to load experiment:', error)
- toast.error(t('experiments.loadError'))
+ toast.error(typeof error === 'string' ? error : t('experiments.loadError'))
onClose()
} finally {
setIsLoading(false)
diff --git a/web/app/pages/UserSettings/UserSettings.tsx b/web/app/pages/UserSettings/UserSettings.tsx
index eea3ee955..e4ef96a8e 100644
--- a/web/app/pages/UserSettings/UserSettings.tsx
+++ b/web/app/pages/UserSettings/UserSettings.tsx
@@ -268,8 +268,8 @@ const UserSettings = () => {
await receiveLoginNotification(checked)
mergeUser({ receiveLoginNotifications: checked })
toast.success(t('profileSettings.updated'))
- } catch {
- toast.error(t('apiNotifications.somethingWentWrong'))
+ } catch (reason: any) {
+ toast.error(typeof reason === 'string' ? reason : t('apiNotifications.somethingWentWrong'))
} finally {
setSettingUpdating(false)
}
@@ -307,7 +307,7 @@ const UserSettings = () => {
toast.success(t('apiNotifications.accountDeleted'))
navigate(routes.main)
} catch (reason: any) {
- toast.error(t(`apiNotifications.${reason}`, 'apiNotifications.somethingWentWrong'))
+ toast.error(typeof reason === 'string' ? reason : t('apiNotifications.somethingWentWrong'))
}
}
diff --git a/web/app/pages/UserSettings/components/Integrations.tsx b/web/app/pages/UserSettings/components/Integrations.tsx
index dd676aa2a..6eaf490ff 100644
--- a/web/app/pages/UserSettings/components/Integrations.tsx
+++ b/web/app/pages/UserSettings/components/Integrations.tsx
@@ -184,12 +184,8 @@ const Integrations = ({ handleIntegrationSave }: IntegrationsProps) => {
isTelegramChatIdConfirmed: false,
telegramChatId: null,
})
- } catch (reason) {
- if (_isString(reason)) {
- toast.error(reason)
- } else {
- toast.error(t('apiNotifications.integrationRemovalError'))
- }
+ } catch (reason: any) {
+ toast.error(typeof reason === 'string' ? reason : t('apiNotifications.integrationRemovalError'))
console.error(`[ERROR] Failed to remove TG integration: ${reason}`)
}