/** * ADRFlow Error Types * * Defines all custom error types used throughout the application. * Each error type has a unique code for programmatic handling. * * @module adrflow/core/errors */ /** * Error codes for programmatic error handling */ export declare const ErrorCode: { readonly STORAGE_NOT_INITIALIZED: "ADRFLOW_1001"; readonly STORAGE_OPEN_FAILED: "ADRFLOW_1002"; readonly STORAGE_WRITE_FAILED: "ADRFLOW_1003"; readonly STORAGE_READ_FAILED: "ADRFLOW_1004"; readonly STORAGE_CORRUPTED: "ADRFLOW_1005"; readonly ADR_NOT_FOUND: "ADRFLOW_2001"; readonly ADR_ALREADY_EXISTS: "ADRFLOW_2002"; readonly ADR_INVALID_ID: "ADRFLOW_2003"; readonly ADR_VALIDATION_FAILED: "ADRFLOW_2004"; readonly ADR_SUPERSEDE_CYCLE: "ADRFLOW_2005"; readonly SEARCH_FAILED: "ADRFLOW_3001"; readonly SEARCH_INVALID_QUERY: "ADRFLOW_3002"; readonly SEARCH_TIMEOUT: "ADRFLOW_3003"; readonly MCP_TOOL_FAILED: "ADRFLOW_4001"; readonly MCP_INVALID_PARAMS: "ADRFLOW_4002"; readonly MCP_RESOURCE_NOT_FOUND: "ADRFLOW_4003"; readonly CONFIG_INVALID: "ADRFLOW_5001"; readonly CONFIG_NOT_FOUND: "ADRFLOW_5002"; readonly UNKNOWN: "ADRFLOW_9999"; }; export type ErrorCode = (typeof ErrorCode)[keyof typeof ErrorCode]; /** * Base class for all ADRFlow errors */ export declare class ADRFlowError extends Error { /** Unique error code */ readonly code: ErrorCode; /** Additional context about the error */ readonly context?: Record; /** Original error if this wraps another error */ readonly cause?: Error; /** Timestamp when the error occurred */ readonly timestamp: Date; constructor(message: string, code: ErrorCode, options?: { context?: Record; cause?: Error; }); /** * Returns a JSON-serializable representation of the error */ toJSON(): Record; } /** * Error thrown when storage operations fail */ export declare class StorageError extends ADRFlowError { constructor(message: string, code: typeof ErrorCode.STORAGE_NOT_INITIALIZED | typeof ErrorCode.STORAGE_OPEN_FAILED | typeof ErrorCode.STORAGE_WRITE_FAILED | typeof ErrorCode.STORAGE_READ_FAILED | typeof ErrorCode.STORAGE_CORRUPTED, options?: { context?: Record; cause?: Error; }); } /** * Error thrown when ADR operations fail */ export declare class ADRError extends ADRFlowError { constructor(message: string, code: typeof ErrorCode.ADR_NOT_FOUND | typeof ErrorCode.ADR_ALREADY_EXISTS | typeof ErrorCode.ADR_INVALID_ID | typeof ErrorCode.ADR_VALIDATION_FAILED | typeof ErrorCode.ADR_SUPERSEDE_CYCLE, options?: { context?: Record; cause?: Error; }); } /** * Error thrown when search operations fail */ export declare class SearchError extends ADRFlowError { constructor(message: string, code: typeof ErrorCode.SEARCH_FAILED | typeof ErrorCode.SEARCH_INVALID_QUERY | typeof ErrorCode.SEARCH_TIMEOUT, options?: { context?: Record; cause?: Error; }); } /** * Error thrown when MCP operations fail */ export declare class MCPError extends ADRFlowError { constructor(message: string, code: typeof ErrorCode.MCP_TOOL_FAILED | typeof ErrorCode.MCP_INVALID_PARAMS | typeof ErrorCode.MCP_RESOURCE_NOT_FOUND, options?: { context?: Record; cause?: Error; }); } /** * Error thrown when configuration is invalid */ export declare class ConfigError extends ADRFlowError { constructor(message: string, code: typeof ErrorCode.CONFIG_INVALID | typeof ErrorCode.CONFIG_NOT_FOUND, options?: { context?: Record; cause?: Error; }); } /** * Wraps an unknown error into an ADRFlowError */ export declare function wrapError(error: unknown, context?: string): ADRFlowError; /** * Extracts error message from unknown error type */ export declare function getErrorMessage(error: unknown): string; /** * Type guard to check if an error is an ADRFlowError */ export declare function isADRFlowError(error: unknown): error is ADRFlowError; /** * Type guard to check if an error has a specific code */ export declare function hasErrorCode(error: unknown, code: ErrorCode): error is ADRFlowError; //# sourceMappingURL=errors.d.ts.map