fix(desktop): read error body instead of statusText for gateway errors

res.statusText is always empty under HTTP/2, causing "Gateway error: "
with no detail. Now reads the JSON response body to surface the
server's actual error message and always includes the status code.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
yushen 2026-02-14 08:51:46 +08:00
parent b3a179971e
commit 0b50400a45

View file

@ -50,11 +50,9 @@ export function TelegramConnectQR({
if (cancelled) return
if (!res.ok) {
if (res.status === 503) {
setError('Telegram bot not configured on Gateway')
} else {
setError(`Gateway error: ${res.statusText}`)
}
const body = (await res.json().catch(() => null)) as { message?: string } | null
const detail = body?.message || `HTTP ${res.status}`
setError(`Gateway error (${res.status}): ${detail}`)
setDeepLink(null)
return
}