/** * Typed error classes and Result pattern for opensip-tools. */ /** * Closed union of canonical error codes carried by `ToolError` and its * subclasses. Open by intent at the consumer layer — callers may pass * any string in `ToolErrorOptions.code` (subclass-specific subcodes * like `'VALIDATION.RECIPE.DUPLICATE'` are common) — but the base * default for each subclass is one of these literals, which means an * `instanceof` check pairs naturally with an exhaustive switch on * `code` for the no-override case. */ export type ToolErrorCode = 'VALIDATION_ERROR' | 'NOT_FOUND' | 'SYSTEM_ERROR' | 'TIMEOUT' | 'NETWORK_ERROR' | 'CONFIGURATION_ERROR' | 'PLUGIN_INCOMPATIBLE' | 'UNKNOWN_LIVE_VIEW'; /** Constructor options for {@link ToolError}: `code` plus arbitrary diagnostic metadata. */ export interface ToolErrorOptions extends ErrorOptions { code?: string; [key: string]: unknown; } /** Base class for all opensip-tools errors; carries a `code` for programmatic dispatch. */ export declare class ToolError extends Error { /** * Error code. Typed as a `string` super-set of `ToolErrorCode` because * subclass call sites may opt into a more specific subcode via * `ToolErrorOptions.code` (e.g. `'VALIDATION.RECIPE.DUPLICATE'`). For * exhaustive-switch use cases, narrow with the `ToolErrorCode` union * after an `instanceof` check. */ readonly code: string; constructor(message: string, code: string, options?: ToolErrorOptions); } /** Thrown when user-supplied input (config, CLI flags, recipes) fails schema or domain validation. */ export declare class ValidationError extends ToolError { constructor(message: string, options?: ToolErrorOptions); } /** Thrown when a named resource (check, recipe, file, session) cannot be located. */ export declare class NotFoundError extends ToolError { constructor(message: string, options?: ToolErrorOptions); } /** Thrown for internal invariant violations or unexpected runtime failures. */ export declare class SystemError extends ToolError { constructor(message: string, options?: ToolErrorOptions); } /** Thrown when an operation exceeds its allotted time budget. */ export declare class TimeoutError extends ToolError { readonly timeoutMs?: number; constructor(message: string, timeoutOrOptions?: number | ToolErrorOptions); } /** Thrown for HTTP or socket-level failures during outbound requests. */ export declare class NetworkError extends ToolError { readonly statusCode?: number; constructor(message: string, options?: ToolErrorOptions & { statusCode?: number; }); } /** Thrown when project or tool configuration is missing, malformed, or contradictory. */ export declare class ConfigurationError extends ToolError { constructor(message: string, options?: ToolErrorOptions); } /** * Thrown when a tool plugin is rejected by the compatibility/trust gate * (release 2.8.0) and the rejection must fail the run rather than skip * silently — i.e. the tool was explicitly requested but is incompatible, * or a project-local executable tool was not allowlisted (deny-by-default). * * Mapped to `EXIT_CODES.PLUGIN_INCOMPATIBLE` (exit 5) by * `mapToolErrorToExitCode` so an incompatible/untrusted plugin is * diagnosable from the exit code alone. Carries the structured * `diagnostic` the admission gate produced (compatibility reason or the * trust-policy message) for surfacing through the CLI error boundary. */ export declare class PluginIncompatibleError extends ToolError { /** The admission diagnostic (compatibility reason or trust-policy message). */ readonly diagnostic?: string; constructor(message: string, options?: ToolErrorOptions & { diagnostic?: string; }); } /** * Thrown when a contribution is routed to a capability domain that no tool * has declared (release 2.10.0, §5.3). A subclass of {@link NotFoundError} * (so existing not-found handling still catches it) that additionally * carries the structured diagnostic the capability registry produced: the * unknown `domainId` and the set of `knownDomains`. Code defaults to * `'CAPABILITY.DOMAIN.UNKNOWN'`. */ export declare class UnknownCapabilityDomainError extends NotFoundError { /** The domain id that was routed to but not declared. */ readonly domainId: string; /** The domain ids that ARE declared on the registry (for diagnostics). */ readonly knownDomains: readonly string[]; constructor(message: string, options: ToolErrorOptions & { domainId: string; knownDomains: readonly string[]; }); } /** * Thrown when a contribution fails the schema check of the capability * domain it targets (release 2.10.0, §5.3). A subclass of * {@link ValidationError} that carries the structured diagnostic: the * `domainId`, the owning tool's `ownerToolId`, and a human-readable * `diagnostic` reason. Code defaults to * `'CAPABILITY.CONTRIBUTION.SCHEMA_MISMATCH'`. */ export declare class CapabilitySchemaMismatchError extends ValidationError { /** The domain id whose schema the contribution failed. */ readonly domainId: string; /** The tool that owns the targeted domain. */ readonly ownerToolId: string; /** Human-readable reason the contribution failed the schema. */ readonly diagnostic: string; constructor(message: string, options: ToolErrorOptions & { domainId: string; ownerToolId: string; diagnostic: string; }); } export type Result = { readonly ok: true; readonly value: T; } | { readonly ok: false; readonly error: E; }; /** Constructs a success {@link Result} carrying `value`. */ export declare function ok(value: T): Result; /** Constructs a failure {@link Result} carrying `error`. */ export declare function err(error: E): Result; /** Wraps an async function in a try/catch, returning a Result instead of throwing. */ export declare function tryCatchAsync(fn: () => Promise): Promise>; /** Wraps a sync function in a try/catch, returning a Result instead of throwing. */ export declare function tryCatch(fn: () => T): Result; //# sourceMappingURL=errors.d.ts.map