import type { StandardSchemaV1 } from '@standard-schema/spec'; import type { PathFaultCode, JsonFaultCode, SourceFaultCode } from '@botejs/native'; import { type Path } from './path.ts'; export type { PathFaultCode, JsonFaultCode, SourceFaultCode }; export type BoteErrorCode = PathFaultCode | JsonFaultCode | SourceFaultCode | 'validation' | 'closed' | 'forward_replay'; /** Base class for every error bote raises from its own logic. Catch this to * catch anything bote throws; branch on {@link BoteError.code} for the precise * kind. Always carries a `bote:`-prefixed message. */ export declare abstract class BoteError extends Error { readonly code: BoteErrorCode; constructor(code: BoteErrorCode, message: string, options?: ErrorOptions); } /** Raised when a `path` cannot be resolved against the document's actual shape - * e.g. it descends through a scalar, or a segment's kind (key vs index) does not * match the container it lands in. `path` is the offending path. */ export declare class PathError extends BoteError { readonly code: PathFaultCode; readonly path: Path; constructor(path: Path, code: PathFaultCode, segment?: number); } /** Raised when a value fails the Standard Schema passed to `get`/`iter` (and only * when the policy is to throw - `has` and `iter`'s `onInvalid: 'skip'` swallow it). * `issues` carries the schema's validation issues; `path` is where the value lived. */ export declare class ValidationError extends BoteError { readonly code: 'validation'; readonly issues: readonly StandardSchemaV1.Issue[]; readonly path: Path; constructor(issues: readonly StandardSchemaV1.Issue[], path: Path); } /** Raised when the bytes at `path` are not valid JSON - either syntactically * malformed or truncated (`unexpected_eof`, e.g. a stream that ended mid-value). * Distinguish the two via {@link BoteError.code}. */ export declare class MalformedJsonError extends BoteError { readonly code: JsonFaultCode; readonly path: Path; constructor(path: Path, code: JsonFaultCode, options?: ErrorOptions); } /** Raised when the underlying source fails to deliver bytes - a file read error, * a failed HTTP fetch, an aborted stream, etc. `detail` (in the message) carries * the backend's reason; the triggering error is attached as `cause`. */ export declare class SourceReadError extends BoteError { readonly code: SourceFaultCode; readonly path: Path; constructor(path: Path, detail: string, options?: ErrorOptions); } /** Raised when a query on a forward-only source needs to re-read bytes before the * point the stream has already passed, and rewinding is forbidden (the default). * `offset` is the byte it wanted; `position` is where the stream had advanced to. * Opt into `rewind: 'replay'` or `'buffer'` (see `fromReadable`), or switch to a * seekable source, to allow the re-read. */ export declare class ForwardReplayError extends BoteError { readonly code: 'forward_replay'; readonly offset: number; readonly position: number; constructor(offset: number, position: number, options?: ErrorOptions); } /** Raised when any operation is attempted on a cursor whose root has been closed * (via `close()` or leaving an `await using` scope). Child cursors share the * root's lifetime, so they throw this too once the root is closed. */ export declare class ClosedCursorError extends BoteError { readonly code: 'closed'; constructor(); } /** Rebuild a typed {@link BoteError} from a native addon error, anchoring it to * the `path` of the call it surfaced through. Pass-through for anything that * isn't a recognized native error (including errors already typed here). */ export declare function deserializeNativeError(err: unknown, path: Path): unknown;