mcp-adr-analysis-server
Version:
MCP server for analyzing Architectural Decision Records and project architecture
173 lines • 7 kB
TypeScript
/**
* Enhanced error types for better user experience
*
* Provides structured error handling with actionable suggestions
* and contextual information to help users resolve issues.
*/
/**
* Base interface for diagnostic context information
*/
export interface DiagnosticContext {
/** Component or module where the error occurred */
component: string;
/** Operation being performed when error occurred */
operation: string;
/** Timestamp when error occurred */
timestamp: Date;
/** Additional context data */
context?: Record<string, any>;
/** Stack trace or call path */
stackTrace?: string;
/** Performance metrics at time of error */
performanceMetrics?: {
memoryUsage?: number;
cpuUsage?: number;
queueSize?: number;
activeOperations?: number;
};
}
/**
* Enhanced base error class with comprehensive diagnostic information
*/
export declare abstract class EnhancedError extends Error {
readonly code: string;
readonly severity: 'critical' | 'high' | 'medium' | 'low';
readonly suggestions: ErrorSuggestion[];
readonly diagnostics: DiagnosticContext;
readonly recoverable: boolean;
readonly retryable: boolean;
constructor(message: string, code: string, options: {
severity?: 'critical' | 'high' | 'medium' | 'low';
suggestions?: ErrorSuggestion[];
diagnostics: DiagnosticContext;
recoverable?: boolean;
retryable?: boolean;
cause?: Error;
});
/**
* Get formatted error message with diagnostic information
*/
getDetailedMessage(): string;
/**
* Convert error to structured object for logging
*/
toLogObject(): Record<string, any>;
}
/**
* Operation Queue specific errors
*/
export declare class OperationQueueError extends EnhancedError {
constructor(message: string, code: string, diagnostics: DiagnosticContext, options?: {
severity?: 'critical' | 'high' | 'medium' | 'low';
suggestions?: ErrorSuggestion[];
recoverable?: boolean;
retryable?: boolean;
cause?: Error;
});
static queueOverflow(queueSize: number, maxSize: number, diagnostics: DiagnosticContext): OperationQueueError;
static operationTimeout(operationId: string, timeoutMs: number, diagnostics: DiagnosticContext): OperationQueueError;
static concurrencyViolation(activeCount: number, maxConcurrency: number, diagnostics: DiagnosticContext): OperationQueueError;
static shutdownInProgress(diagnostics: DiagnosticContext): OperationQueueError;
}
/**
* Data Consistency Checker specific errors
*/
export declare class DataConsistencyError extends EnhancedError {
constructor(message: string, code: string, diagnostics: DiagnosticContext, options?: {
severity?: 'critical' | 'high' | 'medium' | 'low';
suggestions?: ErrorSuggestion[];
recoverable?: boolean;
retryable?: boolean;
cause?: Error;
});
static validationFailure(validationType: string, affectedItems: string[], diagnostics: DiagnosticContext): DataConsistencyError;
static metadataSyncFailure(taskCount: number, metadataCount: number, diagnostics: DiagnosticContext): DataConsistencyError;
static dateValidationFailure(invalidDates: string[], diagnostics: DiagnosticContext): DataConsistencyError;
static circularDependencyDetected(cycle: string[], diagnostics: DiagnosticContext): DataConsistencyError;
}
/**
* Represents an actionable suggestion for resolving an error
*/
export interface ErrorSuggestion {
/** Brief description of the suggested action */
action: string;
/** Detailed explanation of how to perform the action */
description: string;
/** Optional example showing the correct usage */
example?: string;
}
/**
* Enhanced error class for TODO management operations
*
* Provides structured error information with contextual suggestions
* to help users understand and resolve issues quickly.
*
* @example
* ```typescript
* try {
* await manager.updateTask({ taskId: "invalid", updates: {} });
* } catch (error) {
* if (error instanceof TodoManagerError) {
* console.log(`Error: ${error.message}`);
* console.log(`Code: ${error.code}`);
* error.suggestions.forEach(s => {
* console.log(`- ${s.action}: ${s.description}`);
* });
* }
* }
* ```
*/
export declare class TodoManagerError extends Error {
readonly code: string;
readonly field?: string;
readonly value?: any;
readonly validValues?: any[];
readonly suggestions: ErrorSuggestion[];
readonly taskId?: string;
readonly suggestion?: string;
constructor(message: string, code: string, options?: {
field?: string;
value?: any;
validValues?: any[];
suggestions?: ErrorSuggestion[];
taskId?: string;
suggestion?: string;
});
static projectPathNotFound(path: string): TodoManagerError;
/**
* Create a task not found error with helpful suggestions
*
* @param taskId - The task ID that could not be found
* @returns TodoManagerError with suggestions for finding the task
*/
static taskNotFound(taskId: string): TodoManagerError;
/**
* Create an invalid task ID error with format guidance
*
* @param taskId - The invalid task ID that was provided
* @returns TodoManagerError with suggestions for correct ID format
*/
static invalidTaskId(taskId: string): TodoManagerError;
static invalidPriority(value: string, suggestedValue?: string): TodoManagerError;
static taskHasDependencies(taskId: string, dependentTasks: string[]): TodoManagerError;
/**
* Create a circular dependency error with resolution suggestions
*
* @param taskIds - Array of task IDs forming the circular dependency chain
* @returns TodoManagerError with suggestions for breaking the cycle
*/
static circularDependency(taskIds: string[]): TodoManagerError;
static invalidDateFormat(date: string, field?: string): TodoManagerError;
static invalidStatus(value: string, suggestedValue?: string): TodoManagerError;
static requiredFieldMissing(field: string): TodoManagerError;
static invalidFieldValue(field: string, value: any, expectedType?: string): TodoManagerError;
static taskAlreadyExists(taskId: string): TodoManagerError;
static bulkOperationPartialFailure(successful: number, failed: number, errors: string[]): TodoManagerError;
static operationNotSupported(operation: string): TodoManagerError;
static concurrencyConflict(taskId: string): TodoManagerError;
static dataCorruption(details: string): TodoManagerError;
static undoNotAvailable(reason: string): TodoManagerError;
static searchQueryInvalid(query: string, reason: string): TodoManagerError;
static multipleTasksFound(partialId: string, matches: string[]): TodoManagerError;
}
//# sourceMappingURL=enhanced-errors.d.ts.map