UNPKG

@alphabin/trx

Version:

TRX reporter for Playwright tests with Azure Blob Storage upload support

55 lines (54 loc) 1.6 kB
export interface ErrorContext { operation: string; details?: Record<string, any>; recoverable?: boolean; } export interface RetryOptions { maxAttempts: number; baseDelay: number; maxDelay: number; backoffFactor: number; } /** * Enhanced error handling utility for TRX operations */ export declare class ErrorHandler { private static readonly defaultRetryOptions; /** * Handles and categorizes errors with appropriate logging */ static handleError(error: unknown, context: ErrorContext): Error; /** * Executes an async operation with retry logic */ static withRetry<T>(operation: () => Promise<T>, context: ErrorContext, options?: Partial<RetryOptions>): Promise<T>; /** * Safely executes an operation and returns result or null on failure */ static safeExecute<T>(operation: () => Promise<T>, context: ErrorContext, defaultValue?: T | null): Promise<T | null>; /** * Validates configuration and provides helpful error messages */ static validateConfig(config: any): string[]; /** * Checks if an error is likely to be retryable */ private static isRetryableError; /** * Normalizes different error types to Error instances */ private static normalizeError; /** * Validates URL format */ private static isValidUrl; /** * Creates a delay promise */ private static delay; /** * Formats error for user display */ static formatErrorForUser(error: Error, context?: string): string; } export default ErrorHandler;