Merge pull request #7 from SamuelSJames/claude/wonderful-faraday-qxym5t
Surface underlying network error instead of generic 'fetch failed'
This commit is contained in:
commit
af4d2bac31
1 changed files with 12 additions and 1 deletions
|
|
@ -16,6 +16,17 @@ function authHeader(apiKey: string): Record<string, string> {
|
||||||
// Proxmox ships with a self-signed cert by default, which Node's fetch rejects out of the box.
|
// Proxmox ships with a self-signed cert by default, which Node's fetch rejects out of the box.
|
||||||
const insecureDispatcher = new Agent({ connect: { rejectUnauthorized: false } })
|
const insecureDispatcher = new Agent({ connect: { rejectUnauthorized: false } })
|
||||||
|
|
||||||
|
// undici's fetch() wraps the real failure (DNS, TLS, connection refused/timed out) in a generic
|
||||||
|
// "fetch failed" TypeError — unwrap err.cause so the actual reason reaches the UI.
|
||||||
|
function describeFetchError(err: unknown): string {
|
||||||
|
if (err instanceof Error) {
|
||||||
|
const cause = (err as { cause?: unknown }).cause
|
||||||
|
if (cause instanceof Error) return `${err.message}: ${cause.message}`
|
||||||
|
return err.message
|
||||||
|
}
|
||||||
|
return 'Connection failed'
|
||||||
|
}
|
||||||
|
|
||||||
export const proxmox: IntegrationAdapter = {
|
export const proxmox: IntegrationAdapter = {
|
||||||
async testConnection(config, secrets) {
|
async testConnection(config, secrets) {
|
||||||
const baseUrl = config.baseUrl?.replace(/\/$/, '')
|
const baseUrl = config.baseUrl?.replace(/\/$/, '')
|
||||||
|
|
@ -30,7 +41,7 @@ export const proxmox: IntegrationAdapter = {
|
||||||
if (!res.ok) return { ok: false, message: `HTTP ${res.status}` }
|
if (!res.ok) return { ok: false, message: `HTTP ${res.status}` }
|
||||||
return { ok: true, message: 'Connected' }
|
return { ok: true, message: 'Connected' }
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
return { ok: false, message: err instanceof Error ? err.message : 'Connection failed' }
|
return { ok: false, message: describeFetchError(err) }
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue