/** * 0.8.0+: discriminator for the typed-error hierarchy a downstream * MCP catches at the boundary of a tool handler. Returns one of: * * - `'timeout'` — `FetchproxyTimeoutError` (server's `fetchTimeoutMs` fired) * - `'bridge_down'` — `FetchproxyBridgeDownError` (SW eviction; check `retryAttempted`) * - `'http'` — `FetchproxyHttpError` (upstream status outside `expectStatus`) * - `'protocol'` — base `FetchproxyProtocolError` not in the buckets above * (e.g. `no_tab`, `domain_denied`, generic bridge errors) * - `'other'` — anything not a `FetchproxyProtocolError` subclass * (programmer errors, unrelated runtime errors, non-Errors) * * Use this instead of an `instanceof` ladder — order of `instanceof` * checks is easy to get wrong (parent before subclass collapses the * subclass arms onto `'protocol'`). The helper enforces the correct * ordering once and the rest of the cohort can switch on the string. * * @example * import { classifyBridgeError } from '@fetchproxy/server'; * * try { * await client.get('/foo'); * } catch (e) { * switch (classifyBridgeError(e)) { * case 'timeout': return { error: 'bridge timed out', hint: '…' }; * case 'bridge_down': return { error: 'extension SW down', hint: e.hint }; * case 'http': return { error: `HTTP ${e.response.status}` }; * case 'protocol': return { error: 'transport', message: e.message }; * case 'other': throw e; * } * } */ export type BridgeError = 'timeout' | 'bridge_down' | 'http' | 'protocol' | 'other'; export declare function classifyBridgeError(err: unknown): BridgeError;