export enum ErrorCode { VALIDATION_ERROR = 'VALIDATION_ERROR', FILE_PROCESSING_ERROR = 'FILE_PROCESSING_ERROR', HAR_PARSE_ERROR = 'HAR_PARSE_ERROR', SWAGGER_GENERATION_ERROR = 'SWAGGER_GENERATION_ERROR', AI_SERVICE_ERROR = 'AI_SERVICE_ERROR', INTERNAL_ERROR = 'INTERNAL_ERROR', } export interface ErrorContext { service: string; function: string; payload?: Record; originalError?: Error; } export class AppError extends Error { public readonly code: ErrorCode; public readonly context: ErrorContext; public readonly timestamp: Date; constructor(message: string, code: ErrorCode, context: ErrorContext) { super(message); this.name = 'AppError'; this.code = code; this.context = context; this.timestamp = new Date(); Error.captureStackTrace(this, this.constructor); } }