fix: show user-friendly message for network errors (#8748)

## Summary

Replaces cryptic "Failed to fetch" error messages with user-friendly
"Disconnected from backend" messages.

## Changes

- **What**: Detect network fetch errors in the central toast error
handler and display a helpful message with suggested action ("Check if
the server is running")

## Review Focus

The fix is intentionally minimal—only the central `toastErrorHandler` is
modified since all user-facing API errors flow through it.

Fixes COM-1839

┆Issue is synchronized with this [Notion
page](https://www.notion.so/PR-8748-fix-show-user-friendly-message-for-network-errors-3016d73d365081b3869bf19550c9af93)
by [Unito](https://www.unito.io)
This commit is contained in:
Christian Byrne
2026-02-16 03:01:17 -08:00
committed by GitHub
parent 3d88d0a6ab
commit 82ace36982
2 changed files with 9 additions and 1 deletions

View File

@@ -52,10 +52,17 @@ export interface ErrorRecoveryStrategy<
export function useErrorHandling() {
const toast = useToastStore()
const toastErrorHandler = (error: unknown) => {
const isNetworkError =
error instanceof TypeError && error.message === 'Failed to fetch'
const message = isNetworkError
? t('g.disconnectedFromBackend')
: error instanceof Error
? error.message
: t('g.unknownError')
toast.add({
severity: 'error',
summary: t('g.error'),
detail: error instanceof Error ? error.message : t('g.unknownError')
detail: message
})
console.error(error)
}

View File

@@ -98,6 +98,7 @@
"unknownFile": "Unknown file",
"reconnecting": "Reconnecting",
"reconnected": "Reconnected",
"disconnectedFromBackend": "Disconnected from backend. Check if the server is running.",
"delete": "Delete",
"rename": "Rename",
"save": "Save",