UNPKG

@dima_aryze/reforge

Version:

TypeScript/JavaScript SDK for Reforge - Cross-chain token operations

168 lines 5.55 kB
/** * Enhanced error classes for the Reforge SDK */ import type { ApiError } from '../types'; /** * Base error context interface */ export interface ErrorContext { /** Request ID for tracing */ requestId?: string; /** URL that caused the error */ url?: string; /** HTTP method used */ method?: string; /** Timestamp of when error occurred */ timestamp?: Date; /** Additional error metadata */ metadata?: Record<string, any>; } /** * Base Reforge SDK error class with enhanced context */ export declare class ReforgeError extends Error { readonly cause?: Error | undefined; readonly name: string; readonly isReforgeError: boolean; readonly context: ErrorContext; constructor(message: string, cause?: Error | undefined, context?: ErrorContext); /** * Convert error to JSON representation */ toJSON(): Record<string, any>; /** * Get error details for logging */ getDetails(): Record<string, any>; } /** * API-specific error class with enhanced HTTP context */ export declare class ReforgeApiError extends ReforgeError { readonly status: number; readonly code: string; readonly details?: any | undefined; readonly name: string; constructor(message: string, status: number, code: string, details?: any | undefined, cause?: Error, context?: ErrorContext); /** * Create ReforgeApiError from API error response */ static fromApiError(apiError: ApiError, status?: number, context?: ErrorContext): ReforgeApiError; /** * Check if this is a client error (4xx) */ isClientError(): boolean; /** * Check if this is a server error (5xx) */ isServerError(): boolean; /** * Check if this is a specific error code */ hasCode(code: string): boolean; /** * Check if this error indicates a rate limit */ isRateLimit(): boolean; /** * Check if this error indicates authentication failure */ isAuthenticationError(): boolean; /** * Check if this error indicates authorization failure */ isAuthorizationError(): boolean; /** * Enhanced JSON representation */ toJSON(): Record<string, any>; } /** * Network-specific error class with connection details */ export declare class ReforgeNetworkError extends ReforgeError { readonly url?: string | undefined; readonly timeout?: boolean | undefined; readonly name: string; constructor(message: string, url?: string | undefined, timeout?: boolean | undefined, cause?: Error, context?: ErrorContext); /** * Create network error for timeout */ static timeout(url?: string, context?: ErrorContext): ReforgeNetworkError; /** * Create network error for connection issues */ static connection(url?: string, cause?: Error, context?: ErrorContext): ReforgeNetworkError; /** * Create network error for DNS resolution issues */ static dnsResolution(url?: string, context?: ErrorContext): ReforgeNetworkError; /** * Enhanced JSON representation */ toJSON(): Record<string, any>; } /** * Validation error class with field-specific details */ export declare class ReforgeValidationError extends ReforgeError { readonly field?: string | undefined; readonly value?: any | undefined; readonly constraint?: string | undefined; readonly name: string; constructor(message: string, field?: string | undefined, value?: any | undefined, constraint?: string | undefined, cause?: Error, context?: ErrorContext); /** * Create validation error for required field */ static required(field: string, context?: ErrorContext): ReforgeValidationError; /** * Create validation error for invalid value */ static invalid(field: string, value: any, expected?: string, context?: ErrorContext): ReforgeValidationError; /** * Create validation error for format issues */ static format(field: string, value: any, format: string, context?: ErrorContext): ReforgeValidationError; /** * Enhanced JSON representation */ toJSON(): Record<string, any>; } /** * Configuration error class for SDK setup issues */ export declare class ReforgeConfigurationError extends ReforgeError { readonly configKey?: string | undefined; readonly name: string; constructor(message: string, configKey?: string | undefined, cause?: Error, context?: ErrorContext); /** * Create configuration error for missing config */ static missing(configKey: string, context?: ErrorContext): ReforgeConfigurationError; /** * Enhanced JSON representation */ toJSON(): Record<string, any>; } /** * Operation-specific error for reforge operations */ export declare class ReforgeOperationError extends ReforgeError { readonly operation: string; readonly operationData?: any | undefined; readonly name: string; constructor(message: string, operation: string, operationData?: any | undefined, cause?: Error, context?: ErrorContext); /** * Create operation error for initiate failures */ static initiateFailed(reason: string, data?: any, context?: ErrorContext): ReforgeOperationError; /** * Create operation error for finish failures */ static finishFailed(reason: string, data?: any, context?: ErrorContext): ReforgeOperationError; /** * Enhanced JSON representation */ toJSON(): Record<string, any>; } //# sourceMappingURL=index.d.ts.map