mirror of
https://gitea.toothfairyai.com/ToothFairyAI/tf_code.git
synced 2026-04-19 07:04:40 +00:00
fix(opencode): show human-readable message for HTML error responses (#15407)
This commit is contained in:
committed by
GitHub
parent
b15fb21191
commit
6b7e6bde4d
@@ -76,6 +76,18 @@ export namespace ProviderError {
|
|||||||
}
|
}
|
||||||
} catch {}
|
} catch {}
|
||||||
|
|
||||||
|
// If responseBody is HTML (e.g. from a gateway or proxy error page),
|
||||||
|
// provide a human-readable message instead of dumping raw markup
|
||||||
|
if (/^\s*<!doctype|^\s*<html/i.test(e.responseBody)) {
|
||||||
|
if (e.statusCode === 401) {
|
||||||
|
return "Unauthorized: request was blocked by a gateway or proxy. Your authentication token may be missing or expired — try running `opencode auth login <your provider URL>` to re-authenticate."
|
||||||
|
}
|
||||||
|
if (e.statusCode === 403) {
|
||||||
|
return "Forbidden: request was blocked by a gateway or proxy. You may not have permission to access this resource — check your account and provider settings."
|
||||||
|
}
|
||||||
|
return msg
|
||||||
|
}
|
||||||
|
|
||||||
return `${msg}: ${e.responseBody}`
|
return `${msg}: ${e.responseBody}`
|
||||||
}).trim()
|
}).trim()
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user