/** * Error handling types for VC-SYS CLI Supabase integration */ export enum ErrorCategory { VALIDATION = 'VALIDATION', AUTHENTICATION = 'AUTHENTICATION', AUTHORIZATION = 'AUTHORIZATION', API = 'API', DATABASE = 'DATABASE', FILE_SYSTEM = 'FILE_SYSTEM', NETWORK = 'NETWORK', TIMEOUT = 'TIMEOUT', PROVISIONING = 'PROVISIONING', INTERNAL = 'INTERNAL' } export class ProvisioningError extends Error { public readonly category: ErrorCategory; public readonly timestamp: Date; public readonly context?: Record; constructor(message: string, category: ErrorCategory, context?: Record) { super(message); this.name = 'ProvisioningError'; this.category = category; this.timestamp = new Date(); this.context = context; } toJSON() { return { name: this.name, message: this.message, category: this.category, timestamp: this.timestamp.toISOString(), context: this.context }; } } export interface ErrorRecoveryStrategy { canRecover: boolean; retryable: boolean; maxRetries?: number; backoffMs?: number; recoveryAction?: () => Promise; } export const ERROR_RECOVERY_STRATEGIES: Record = { [ErrorCategory.VALIDATION]: { canRecover: false, retryable: false }, [ErrorCategory.AUTHENTICATION]: { canRecover: true, retryable: true, maxRetries: 3, backoffMs: 1000 }, [ErrorCategory.AUTHORIZATION]: { canRecover: false, retryable: false }, [ErrorCategory.API]: { canRecover: true, retryable: true, maxRetries: 5, backoffMs: 2000 }, [ErrorCategory.DATABASE]: { canRecover: true, retryable: true, maxRetries: 3, backoffMs: 5000 }, [ErrorCategory.FILE_SYSTEM]: { canRecover: true, retryable: true, maxRetries: 2, backoffMs: 500 }, [ErrorCategory.NETWORK]: { canRecover: true, retryable: true, maxRetries: 5, backoffMs: 1000 }, [ErrorCategory.TIMEOUT]: { canRecover: true, retryable: true, maxRetries: 2, backoffMs: 5000 }, [ErrorCategory.PROVISIONING]: { canRecover: true, retryable: false }, [ErrorCategory.INTERNAL]: { canRecover: false, retryable: false } };