taskflow-ai
Version:
TaskFlow AI - 智能PRD文档解析与任务管理助手,支持多模型AI协同、MCP编辑器集成,专为开发团队设计的CLI工具
121 lines (120 loc) • 3.06 kB
TypeScript
/**
* 错误注册中心
* 统一管理所有错误类型和错误处理策略
*/
import { TaskFlowError, ErrorContext } from './typed-errors';
/**
* 错误类型枚举
*/
export declare enum ErrorType {
VALIDATION_ERROR = "VALIDATION_ERROR",
CONFIGURATION_ERROR = "CONFIGURATION_ERROR",
NETWORK_ERROR = "NETWORK_ERROR",
API_ERROR = "API_ERROR",
TIMEOUT_ERROR = "TIMEOUT_ERROR",
FILESYSTEM_ERROR = "FILESYSTEM_ERROR",
PERMISSION_ERROR = "PERMISSION_ERROR",
PARSE_ERROR = "PARSE_ERROR",
FORMAT_ERROR = "FORMAT_ERROR",
BUSINESS_LOGIC_ERROR = "BUSINESS_LOGIC_ERROR",
RESOURCE_NOT_FOUND = "RESOURCE_NOT_FOUND",
DUPLICATE_RESOURCE = "DUPLICATE_RESOURCE",
SYSTEM_ERROR = "SYSTEM_ERROR",
MEMORY_ERROR = "MEMORY_ERROR",
UNKNOWN_ERROR = "UNKNOWN_ERROR"
}
/**
* 错误严重级别
*/
export declare enum ErrorSeverity {
LOW = "low",
MEDIUM = "medium",
HIGH = "high",
CRITICAL = "critical"
}
/**
* 错误恢复策略
*/
export declare enum RecoveryStrategy {
NONE = "none",
RETRY = "retry",
FALLBACK = "fallback",
USER_INPUT = "user_input",
GRACEFUL_DEGRADATION = "graceful_degradation"
}
/**
* 错误定义接口
*/
export interface ErrorDefinition {
type: ErrorType;
severity: ErrorSeverity;
recoveryStrategy: RecoveryStrategy;
userMessage: string;
technicalMessage: string;
suggestions: string[];
documentationUrl?: string;
retryable: boolean;
maxRetries?: number;
retryDelay?: number;
}
/**
* 错误注册中心类
*/
export declare class ErrorRegistry {
private static instance;
private errorDefinitions;
private constructor();
static getInstance(): ErrorRegistry;
/**
* 注册错误定义
*/
registerError(definition: ErrorDefinition): void;
/**
* 获取错误定义
*/
getErrorDefinition(type: ErrorType): ErrorDefinition | undefined;
/**
* 创建标准化错误
*/
createError(type: ErrorType, message: string, context?: Partial<ErrorContext>): TaskFlowError;
/**
* 获取错误恢复建议
*/
getRecoveryActions(type: ErrorType): string[];
/**
* 检查错误是否可重试
*/
isRetryable(type: ErrorType): boolean;
/**
* 获取最大重试次数
*/
getMaxRetries(type: ErrorType): number;
/**
* 获取重试延迟
*/
getRetryDelay(type: ErrorType): number;
/**
* 初始化默认错误定义
*/
private initializeDefaultErrors;
/**
* 获取所有错误类型
*/
getAllErrorTypes(): ErrorType[];
/**
* 获取错误统计信息
*/
getErrorStats(): {
totalTypes: number;
retryableTypes: number;
severityDistribution: Record<ErrorSeverity, number>;
};
}
/**
* 便捷函数
*/
export declare function getErrorRegistry(): ErrorRegistry;
/**
* 创建标准化错误
*/
export declare function createStandardError(type: ErrorType, message: string, context?: Partial<ErrorContext>): TaskFlowError;