/** * Structured error codes for graph handlers. * * Before v1.4.0 graph handlers threw raw `Error`s with string messages, so * hosts had to grep for substrings (`'Catalog Error'`, `'binder error'`, …) * to differentiate "graph data is empty" from "infrastructure broken" from * "user-supplied filter is bad". That made fallback routing fragile. * * `GraphError` extends `Error` (so `instanceof Error` keeps working and the * `message` field is unchanged) and adds a coarse `.code` enum the host can * pattern-match on: * * - `'NO_NODES'` / `'NO_EDGES'` — the graph has no nodes / no edges. * Today handlers return `success: true` with empty results in this * case, but a host that wants to short-circuit can throw a `GraphError` * itself to trigger an alternate flow. * - `'INVALID_FILTER'` — the user-supplied `filter:` clause was * rejected by DuckDB. Host should re-prompt the user, not retry. * - `'INVALID_INPUT'` — Zod validation failure or other input * contract violation. Host should fix the call site, not retry. * - `'NO_PATH'` — `graph.weighted_path` could not reach * `target_node` from `source_node` within `max_hops`. Host can decide * whether to relax max_hops or report no-path. * - `'TIMEOUT'` — query exceeded its budget. * - `'INFRA'` — anything else: connection lost, DuckDB * internal error, OOM, etc. Host should treat as transient and retry * with backoff, OR surface as "infra issue, please retry". * * @since v1.4.0 */ export type GraphErrorCode = 'NO_NODES' | 'NO_EDGES' | 'INVALID_FILTER' | 'INVALID_INPUT' | 'NO_PATH' | 'TIMEOUT' | 'INFRA'; export declare class GraphError extends Error { readonly code: GraphErrorCode; constructor(code: GraphErrorCode, message: string, options?: { cause?: unknown; }); /** * Wrap an arbitrary thrown value into a GraphError with the `INFRA` code, * preserving the original error as `cause`. No-op if the value is already * a GraphError. * * Heuristic: messages mentioning a "Binder", "Catalog", or "Parser" error * from DuckDB applied to a user filter become `INVALID_FILTER`; everything * else stays `INFRA`. This is a coarse but useful first cut — the audit * called this out as the v1.4.0 starting point, hosts can add finer * classification on top. */ static fromUnknown(error: unknown, hint?: { context?: 'filter' | 'query'; }): GraphError; } //# sourceMappingURL=graph-errors.d.ts.map