UNPKG

agentic-qe

Version:

Agentic Quality Engineering Fleet System - AI-driven quality management platform

226 lines 8.74 kB
"use strict"; /** * Error type definitions for Agentic QE Framework */ Object.defineProperty(exports, "__esModule", { value: true }); exports.formatErrorForLogging = exports.getErrorCategory = exports.createErrorFromCode = exports.isQEError = exports.NetworkError = exports.MemoryError = exports.ResourceError = exports.ConfigurationError = exports.SystemError = exports.QualityMetricsError = exports.DefectPredictionError = exports.CoverageAnalysisError = exports.QualityGateError = exports.QualityError = exports.TestValidationError = exports.TestFrameworkError = exports.TestExecutionError = exports.TestGenerationError = exports.TestError = exports.AgentCapabilityError = exports.AgentTimeoutError = exports.AgentCommunicationError = exports.AgentSpawnError = exports.AgentError = exports.QEError = void 0; // ============================================================================ // Base Error Classes // ============================================================================ class QEError extends Error { constructor(message, context = {}) { super(message); this.timestamp = new Date(); this.name = this.constructor.name; this.context = context; if (Error.captureStackTrace) { Error.captureStackTrace(this, this.constructor); } } toJSON() { return { name: this.name, code: this.code, category: this.category, message: this.message, timestamp: this.timestamp, context: this.context, stack: this.stack }; } } exports.QEError = QEError; // ============================================================================ // Agent Errors // ============================================================================ class AgentError extends QEError { constructor() { super(...arguments); this.category = 'agent'; } } exports.AgentError = AgentError; class AgentSpawnError extends AgentError { constructor(agentType, reason, context = {}) { super(`Failed to spawn agent of type '${agentType}': ${reason}`, context); this.code = 'AGENT_SPAWN_FAILED'; } } exports.AgentSpawnError = AgentSpawnError; class AgentCommunicationError extends AgentError { constructor(fromAgent, toAgent, reason, context = {}) { super(`Communication failed from ${fromAgent} to ${toAgent}: ${reason}`, context); this.code = 'AGENT_COMMUNICATION_FAILED'; } } exports.AgentCommunicationError = AgentCommunicationError; class AgentTimeoutError extends AgentError { constructor(agentId, operation, timeout, context = {}) { super(`Agent ${agentId} timed out during ${operation} after ${timeout}ms`, context); this.code = 'AGENT_TIMEOUT'; } } exports.AgentTimeoutError = AgentTimeoutError; class AgentCapabilityError extends AgentError { constructor(agentId, requiredCapability, context = {}) { super(`Agent ${agentId} missing required capability: ${requiredCapability}`, context); this.code = 'AGENT_CAPABILITY_MISSING'; } } exports.AgentCapabilityError = AgentCapabilityError; // ============================================================================ // Test Errors // ============================================================================ class TestError extends QEError { constructor() { super(...arguments); this.category = 'test'; } } exports.TestError = TestError; class TestGenerationError extends TestError { constructor(reason, context = {}) { super(`Test generation failed: ${reason}`, context); this.code = 'TEST_GENERATION_FAILED'; } } exports.TestGenerationError = TestGenerationError; class TestExecutionError extends TestError { constructor(testId, reason, context = {}) { super(`Test execution failed for ${testId}: ${reason}`, context); this.code = 'TEST_EXECUTION_FAILED'; } } exports.TestExecutionError = TestExecutionError; class TestFrameworkError extends TestError { constructor(framework, reason, context = {}) { super(`Test framework error (${framework}): ${reason}`, context); this.code = 'TEST_FRAMEWORK_ERROR'; } } exports.TestFrameworkError = TestFrameworkError; class TestValidationError extends TestError { constructor(testId, validationRule, context = {}) { super(`Test validation failed for ${testId}: ${validationRule}`, context); this.code = 'TEST_VALIDATION_FAILED'; } } exports.TestValidationError = TestValidationError; // ============================================================================ // Quality Errors // ============================================================================ class QualityError extends QEError { constructor() { super(...arguments); this.category = 'quality'; } } exports.QualityError = QualityError; class QualityGateError extends QualityError { constructor(gateId, reason, context = {}) { super(`Quality gate ${gateId} failed: ${reason}`, context); this.code = 'QUALITY_GATE_FAILED'; } } exports.QualityGateError = QualityGateError; class CoverageAnalysisError extends QualityError { constructor(reason, context = {}) { super(`Coverage analysis failed: ${reason}`, context); this.code = 'COVERAGE_ANALYSIS_FAILED'; } } exports.CoverageAnalysisError = CoverageAnalysisError; class DefectPredictionError extends QualityError { constructor(reason, context = {}) { super(`Defect prediction failed: ${reason}`, context); this.code = 'DEFECT_PREDICTION_FAILED'; } } exports.DefectPredictionError = DefectPredictionError; class QualityMetricsError extends QualityError { constructor(metric, reason, context = {}) { super(`Quality metrics error for ${metric}: ${reason}`, context); this.code = 'QUALITY_METRICS_ERROR'; } } exports.QualityMetricsError = QualityMetricsError; // ============================================================================ // System Errors // ============================================================================ class SystemError extends QEError { constructor() { super(...arguments); this.category = 'system'; } } exports.SystemError = SystemError; class ConfigurationError extends SystemError { constructor(configKey, reason, context = {}) { super(`Configuration error for ${configKey}: ${reason}`, context); this.code = 'CONFIGURATION_ERROR'; } } exports.ConfigurationError = ConfigurationError; class ResourceError extends SystemError { constructor(resource, reason, context = {}) { super(`Resource error for ${resource}: ${reason}`, context); this.code = 'RESOURCE_ERROR'; } } exports.ResourceError = ResourceError; class MemoryError extends SystemError { constructor(operation, reason, context = {}) { super(`Memory error during ${operation}: ${reason}`, context); this.code = 'MEMORY_ERROR'; } } exports.MemoryError = MemoryError; class NetworkError extends SystemError { constructor(operation, reason, context = {}) { super(`Network error during ${operation}: ${reason}`, context); this.code = 'NETWORK_ERROR'; } } exports.NetworkError = NetworkError; // ============================================================================ // Error Utilities // ============================================================================ function isQEError(error) { return error instanceof QEError; } exports.isQEError = isQEError; function createErrorFromCode(code, message, context = {}) { switch (code) { case 'AGENT_SPAWN_FAILED': return new AgentSpawnError('unknown', message, context); case 'TEST_GENERATION_FAILED': return new TestGenerationError(message, context); case 'QUALITY_GATE_FAILED': return new QualityGateError('unknown', message, context); case 'CONFIGURATION_ERROR': return new ConfigurationError('unknown', message, context); default: return new ConfigurationError('unknown', message, context); } } exports.createErrorFromCode = createErrorFromCode; function getErrorCategory(error) { if (isQEError(error)) { return error.category; } return 'unknown'; } exports.getErrorCategory = getErrorCategory; function formatErrorForLogging(error) { if (isQEError(error)) { return error.toJSON(); } return { name: error.name, message: error.message, stack: error.stack, timestamp: new Date() }; } exports.formatErrorForLogging = formatErrorForLogging; //# sourceMappingURL=errors.js.map