UNPKG

mcp-ai-agent-guidelines

Version:

A comprehensive Model Context Protocol server providing advanced tools, resources, and prompts for implementing AI agent best practices

101 lines 3.14 kB
/** * Centralized error handling utilities with typed errors for improved debugging and resilience */ /** * Base class for all operational errors in the application */ export declare class OperationError extends Error { readonly code: string; readonly context?: Record<string, unknown>; readonly timestamp: Date; constructor(message: string, code: string, context?: Record<string, unknown>); } /** * Validation error for input validation failures */ export declare class ValidationError extends OperationError { constructor(message: string, context?: Record<string, unknown>); } /** * Configuration error for invalid or missing configuration */ export declare class ConfigurationError extends OperationError { constructor(message: string, context?: Record<string, unknown>); } /** * Session error for session-related issues */ export declare class SessionError extends OperationError { constructor(message: string, context?: Record<string, unknown>); } /** * Phase error for design phase workflow issues */ export declare class PhaseError extends OperationError { constructor(message: string, context?: Record<string, unknown>); } /** * Generation error for artifact generation failures */ export declare class GenerationError extends OperationError { constructor(message: string, context?: Record<string, unknown>); } /** * Consistency error for consistency enforcement failures */ export declare class ConsistencyError extends OperationError { constructor(message: string, context?: Record<string, unknown>); } /** * Centralized error reporter for consistent error handling */ export declare class ErrorReporter { /** * Report and log an error, optionally rethrowing it */ static report(error: Error | unknown, context?: Record<string, unknown>, options?: { rethrow?: boolean; defaultMessage?: string; }): OperationError; /** * Report a non-critical error as a warning */ static warn(error: Error | unknown, context?: Record<string, unknown>, defaultMessage?: string): void; /** * Convert any error to an OperationError */ private static toOperationError; /** * Extract error message from various error types */ private static extractMessage; /** * Create a safe error response for API returns */ static createErrorResponse(error: Error | unknown, context?: Record<string, unknown>): { success: false; error: { message: string; code: string; timestamp: string; context?: Record<string, unknown>; }; }; /** * Create a full error response with standard fields */ static createFullErrorResponse<T = unknown>(error: Error | unknown, baseResponse: { sessionId: string; status?: string; recommendations?: string[]; artifacts?: T[]; }): { success: false; sessionId: string; status: string; message: string; recommendations: string[]; artifacts: T[]; }; } //# sourceMappingURL=errors.d.ts.map