import { ErrorSeverity, ErrorCategory, ErrorRecoverability } from './error.codes.js'; /** * Context information added to structured errors */ export interface IErrorContext { /** Component or service where the error occurred */ component?: string; /** Operation that was being performed */ operation?: string; /** Unique request ID if available */ requestId?: string; /** Error occurred at timestamp */ timestamp?: number; /** User-visible message (safe to display to end-users) */ userMessage?: string; /** Additional structured data for debugging */ data?: Record; /** Related entity IDs if applicable */ entity?: { type: string; id: string | number; }; /** Stack trace (if enabled in configuration) */ stack?: string; /** Retry information if applicable */ retry?: { /** Maximum number of retries allowed */ maxRetries?: number; /** Current retry count */ currentRetry?: number; /** Next retry timestamp */ nextRetryAt?: number; /** Delay between retries (in ms) */ retryDelay?: number; }; } /** * Base class for all errors in the Platform Service * Adds structured error information, logging, and error tracking */ export declare class PlatformError extends Error { /** Error code identifying the specific error type */ readonly code: string; /** Error severity level */ readonly severity: ErrorSeverity; /** Error category for grouping related errors */ readonly category: ErrorCategory; /** Whether the error can be recovered from automatically */ readonly recoverability: ErrorRecoverability; /** Additional context information */ readonly context: IErrorContext; /** * Creates a new PlatformError * * @param message Error message * @param code Error code from error.codes.ts * @param severity Error severity level * @param category Error category * @param recoverability Error recoverability indication * @param context Additional context information */ constructor(message: string, code: string, severity?: ErrorSeverity, category?: ErrorCategory, recoverability?: ErrorRecoverability, context?: IErrorContext); /** * Logs the error using the platform logger */ private logError; /** * Maps severity levels to log levels */ private getLogLevelFromSeverity; /** * Returns a JSON representation of the error */ toJSON(): Record; /** * Creates an instance with retry information * * @param maxRetries Maximum number of retries * @param currentRetry Current retry count * @param retryDelay Delay between retries in ms */ withRetry(maxRetries: number, currentRetry?: number, retryDelay?: number): PlatformError; /** * Protected method to create a new instance with updated context * Subclasses can override this to handle their own constructor signatures */ protected createWithContext(context: IErrorContext): PlatformError; /** * Checks if the error should be retried based on retry information */ shouldRetry(): boolean; /** * Returns a user-friendly message that is safe to display to end users */ getUserMessage(): string; } /** * Error class for validation errors */ export declare class ValidationError extends PlatformError { /** * Creates a new validation error * * @param message Error message * @param code Error code * @param context Additional context */ constructor(message: string, code: string, context?: IErrorContext); /** * Creates a new instance with updated context * Overrides the base implementation to handle ValidationError's constructor signature */ protected createWithContext(context: IErrorContext): PlatformError; } /** * Error class for configuration errors */ export declare class ConfigurationError extends PlatformError { /** * Creates a new configuration error * * @param message Error message * @param code Error code * @param context Additional context */ constructor(message: string, code: string, context?: IErrorContext); /** * Creates a new instance with updated context * Overrides the base implementation to handle ConfigurationError's constructor signature */ protected createWithContext(context: IErrorContext): PlatformError; } /** * Error class for network-related errors */ export declare class NetworkError extends PlatformError { /** * Creates a new network error * * @param message Error message * @param code Error code * @param context Additional context */ constructor(message: string, code: string, context?: IErrorContext); /** * Creates a new instance with updated context * Overrides the base implementation to handle NetworkError's constructor signature */ protected createWithContext(context: IErrorContext): PlatformError; } /** * Error class for resource availability errors (rate limits, quotas) */ export declare class ResourceError extends PlatformError { /** * Creates a new resource error * * @param message Error message * @param code Error code * @param context Additional context */ constructor(message: string, code: string, context?: IErrorContext); /** * Creates a new instance with updated context * Overrides the base implementation to handle ResourceError's constructor signature */ protected createWithContext(context: IErrorContext): PlatformError; } /** * Error class for authentication/authorization errors */ export declare class AuthenticationError extends PlatformError { /** * Creates a new authentication error * * @param message Error message * @param code Error code * @param context Additional context */ constructor(message: string, code: string, context?: IErrorContext); /** * Creates a new instance with updated context * Overrides the base implementation to handle AuthenticationError's constructor signature */ protected createWithContext(context: IErrorContext): PlatformError; } /** * Error class for operation errors (API calls, processing) */ export declare class OperationError extends PlatformError { /** * Creates a new operation error * * @param message Error message * @param code Error code * @param context Additional context */ constructor(message: string, code: string, context?: IErrorContext); /** * Creates a new instance with updated context * Overrides the base implementation to handle OperationError's constructor signature */ protected createWithContext(context: IErrorContext): PlatformError; } /** * Error class for critical system errors */ export declare class SystemError extends PlatformError { /** * Creates a new system error * * @param message Error message * @param code Error code * @param context Additional context */ constructor(message: string, code: string, context?: IErrorContext); } /** * Helper to get the appropriate error class based on error category * * @param category Error category * @returns The appropriate error class */ export declare function getErrorClassForCategory(category: ErrorCategory): any;