mirror of
https://github.com/Comfy-Org/ComfyUI_frontend.git
synced 2026-02-19 22:34:15 +00:00
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:
@@ -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)
|
||||
}
|
||||
|
||||
@@ -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",
|
||||
|
||||
Reference in New Issue
Block a user