/** * Typed errors thrown by the Verlon SDK. * * Every error extends the standard `Error` so existing * `try { ... } catch (e) { console.error(e.message) }` flows keep * working. The typed subclasses add structured fields the caller can * read programmatically — `VerlonTemplateError.missingVars`, etc. * * The SDK detects an error class by inspecting the API response * (which uses the flat shape `{ error: , message, details? }`). * When the `error` field matches a known code, the SDK throws the * matching class. Otherwise it throws a plain `Error` with the * server's message, preserving the prior behavior. */ /** * The flat error shape Verlon's API uses on every non-compat route. * Mirrors `apps/api/src/middleware/route-handler.ts`'s default shape. */ export interface VerlonErrorResponse { error: string; message: string; details?: unknown; } /** * Thrown when the API returns `400 MISSING_TEMPLATE_VARS` — the gate * has a templated `system_prompt` (containing `{{var}}` placeholders) * and the caller did not supply values for one or more required * variables in the `vars` field of the request. * * Recovery: read `missingVars` to learn which variables are needed, * fetch their values from app state, retry the request with the * filled-in `vars` map. */ export declare class VerlonTemplateError extends Error { /** Stable error code (always `'MISSING_TEMPLATE_VARS'` for this class). */ readonly code: "MISSING_TEMPLATE_VARS"; /** * Variable names the gate's `system_prompt` requires but the caller * did not provide. Order matches the API response (source order in * the template, de-duplicated). Empty array is unexpected; if you * see it, the API or SDK has a bug — report it. */ readonly missingVars: string[]; constructor(message: string, missingVars: string[]); } /** * Inspect a parsed API error response and return the matching typed * error if the response is a known shape. Falls back to a plain * `Error` so the SDK preserves its prior behavior for every other * failure mode. * * Exposed so `client.ts` can dispatch on it from both the JSON-body * code path (`request`) and the streaming code path (`chatStream`), * which read the same envelope shape but live in different functions. */ export declare function buildVerlonError(body: unknown): Error; //# sourceMappingURL=errors.d.ts.map