/** * MAMA Error Classes - Typed Error Handling * * Story 8.3: Typed Error Classes * Provides consistent error handling across MCP tools and core modules * * Error codes follow MCP standard response format: * {error: {code: 'ERROR_CODE', message: '...', details: {}}} * * @module errors * @version 1.0 */ export interface ErrorDetails { [key: string]: unknown; } export interface ErrorResponse { error: { code: string; message: string; details: ErrorDetails; }; } export interface ErrorJSON { name: string; code: string; message: string; details: ErrorDetails; timestamp: string; stack?: string; } /** * Base error class for all MAMA errors */ export declare class MAMAError extends Error { code: string; details: ErrorDetails; timestamp: string; constructor(message: string, code?: string, details?: ErrorDetails); /** * Convert to MCP-compatible error response format */ toResponse(): ErrorResponse; /** * Convert to JSON for logging */ toJSON(): ErrorJSON; } /** * Error thrown when a decision is not found */ export declare class NotFoundError extends MAMAError { constructor(resourceType: string, identifier: string, details?: ErrorDetails); } /** * Error thrown when input validation fails */ export declare class ValidationError extends MAMAError { field: string; constructor(field: string, message: string, received?: unknown, details?: ErrorDetails); } /** * Error thrown when database operations fail */ export declare class DatabaseError extends MAMAError { operation: string; constructor(operation: string, message: string, details?: ErrorDetails); } /** * Error thrown when embedding generation fails */ export declare class EmbeddingError extends MAMAError { constructor(message: string, details?: ErrorDetails); } /** * Error thrown when configuration is invalid */ export declare class ConfigurationError extends MAMAError { configKey: string; constructor(configKey: string, message: string, details?: ErrorDetails); } /** * Error thrown when a link operation fails */ export declare class LinkError extends MAMAError { operation: string; constructor(operation: string, message: string, details?: ErrorDetails); } /** * Error thrown when rate limit is exceeded */ export declare class RateLimitError extends MAMAError { retryAfterMs: number; constructor(operation: string, retryAfterMs: number, details?: ErrorDetails); } /** * Error thrown when operation times out */ export declare class TimeoutError extends MAMAError { timeoutMs: number; constructor(operation: string, timeoutMs: number, details?: ErrorDetails); } /** * Error codes enum for reference */ export declare const ErrorCodes: { readonly DECISION_NOT_FOUND: "DECISION_NOT_FOUND"; readonly CHECKPOINT_NOT_FOUND: "CHECKPOINT_NOT_FOUND"; readonly LINK_NOT_FOUND: "LINK_NOT_FOUND"; readonly INVALID_INPUT: "INVALID_INPUT"; readonly MISSING_REQUIRED_FIELD: "MISSING_REQUIRED_FIELD"; readonly INVALID_FORMAT: "INVALID_FORMAT"; readonly DATABASE_ERROR: "DATABASE_ERROR"; readonly CONNECTION_FAILED: "CONNECTION_FAILED"; readonly QUERY_FAILED: "QUERY_FAILED"; readonly EMBEDDING_ERROR: "EMBEDDING_ERROR"; readonly CONFIG_ERROR: "CONFIG_ERROR"; readonly LINK_ERROR: "LINK_ERROR"; readonly RATE_LIMITED: "RATE_LIMITED"; readonly TIMEOUT: "TIMEOUT"; readonly INTERNAL_ERROR: "INTERNAL_ERROR"; }; export type ErrorCode = (typeof ErrorCodes)[keyof typeof ErrorCodes]; /** * Helper function to wrap unknown errors */ export declare function wrapError(error: unknown, context?: string): MAMAError; /** * Helper function to check if an error is a MAMA error */ export declare function isMAMAError(error: unknown): error is MAMAError; //# sourceMappingURL=errors.d.ts.map