UNPKG

pm-orchestrator-enhancement

Version:

PM Orchestrator Enhancement - Multi-agent parallel execution system

123 lines 4.43 kB
"use strict"; /** * PM Orchestrator Enhancement - Error Handler * * エラー分類、リトライ可否判定、自動修正可否判定、ロールバック必要性判定を行います。 */ Object.defineProperty(exports, "__esModule", { value: true }); exports.ErrorHandler = void 0; const error_types_1 = require("./error-types"); /** * ErrorHandlerクラス * * エラーを分類し、処理戦略を決定します。 */ class ErrorHandler { /** * エラーを分類します * * @param error エラーオブジェクト * @returns エラータイプ */ classify(error) { const message = error.message.toLowerCase(); // ネットワークエラー if (message.includes('network') || message.includes('econnrefused') || message.includes('enotfound') || message.includes('etimedout')) { return error_types_1.ErrorType.NETWORK_ERROR; } // タイムアウト if (message.includes('timeout')) { return error_types_1.ErrorType.TIMEOUT; } // 一時的な失敗 if (message.includes('temporary') || message.includes('retry') || message.includes('unavailable')) { return error_types_1.ErrorType.TEMPORARY_FAILURE; } // Lintエラー if (message.includes('lint') || message.includes('eslint')) { return error_types_1.ErrorType.LINT_ERROR; } // フォーマットエラー if (message.includes('format') || message.includes('prettier')) { return error_types_1.ErrorType.FORMAT_ERROR; } // 設計ミスマッチ("specification"を含む可能性があるため、test判定より前に配置) if (message.includes('design') || message.includes('mismatch')) { return error_types_1.ErrorType.DESIGN_MISMATCH; } // テスト失敗 if (message.includes('test') || message.includes('jest') || message.includes('spec')) { return error_types_1.ErrorType.TEST_FAILURE; } // ビルド失敗 if (message.includes('build') || message.includes('compile')) { return error_types_1.ErrorType.BUILD_FAILURE; } // ルール違反 if (message.includes('rule') || message.includes('violation')) { return error_types_1.ErrorType.RULE_VIOLATION; } // 依存関係エラー if (message.includes('dependency') || message.includes('module') || message.includes('import')) { return error_types_1.ErrorType.DEPENDENCY_ERROR; } // 不明なエラー return error_types_1.ErrorType.UNKNOWN; } /** * リトライ可能かどうかを判定します * * @param errorType エラータイプ * @returns リトライ可能な場合はtrue */ canRetry(errorType) { return [ error_types_1.ErrorType.NETWORK_ERROR, error_types_1.ErrorType.TIMEOUT, error_types_1.ErrorType.TEMPORARY_FAILURE ].includes(errorType); } /** * 自動修正可能かどうかを判定します * * @param errorType エラータイプ * @returns 自動修正可能な場合はtrue */ canAutoFix(errorType) { return [error_types_1.ErrorType.LINT_ERROR, error_types_1.ErrorType.FORMAT_ERROR].includes(errorType); } /** * ロールバックが必要かどうかを判定します * * @param errorType エラータイプ * @returns ロールバックが必要な場合はtrue */ needsRollback(errorType) { return [error_types_1.ErrorType.TEST_FAILURE, error_types_1.ErrorType.BUILD_FAILURE].includes(errorType); } /** * ユーザー介入が必要かどうかを判定します * * @param errorType エラータイプ * @returns ユーザー介入が必要な場合はtrue */ needsUserIntervention(errorType) { return [ error_types_1.ErrorType.RULE_VIOLATION, error_types_1.ErrorType.DESIGN_MISMATCH, error_types_1.ErrorType.DEPENDENCY_ERROR, error_types_1.ErrorType.UNKNOWN ].includes(errorType); } } exports.ErrorHandler = ErrorHandler; //# sourceMappingURL=error-handler.js.map