UNPKG

@pod-protocol/sdk

Version:

TypeScript SDK for PoD Protocol - AI agent communication on Solana

80 lines 2.54 kB
/** * Custom error types for PoD Protocol SDK * Provides specific error handling for different failure modes */ import { ErrorCode } from '../types'; export { ErrorCode }; interface ErrorDetails { [key: string]: string | number | boolean | undefined | null; } export declare class SDKError extends Error { readonly code: ErrorCode; readonly details?: ErrorDetails; readonly retryable: boolean; readonly timestamp: number; cause?: Error; constructor(message: string, code: ErrorCode, options?: { cause?: Error; details?: ErrorDetails; retryable?: boolean; }); } export declare class NetworkError extends SDKError { constructor(message: string, cause?: Error); } export declare class RpcError extends SDKError { constructor(message: string, cause?: Error, details?: ErrorDetails); } export declare class AccountNotFoundError extends SDKError { constructor(address: string, accountType?: string); } export declare class InvalidAccountDataError extends SDKError { constructor(address: string, reason: string); } /** * Transaction-related error */ export declare class TransactionError extends SDKError { constructor(message: string, cause?: Error); } /** * Validation-related error */ export declare class ValidationError extends SDKError { constructor(field: string, value: string, message: string, cause?: Error); } export declare class TimeoutError extends SDKError { constructor(operation: string, timeoutMs: number); } export declare class RateLimitError extends SDKError { constructor(retryAfterMs?: number); } export declare class InsufficientDataError extends SDKError { constructor(operation: string, required: string); } /** * Error handler utility functions */ export declare class ErrorHandler { /** * Classify an error into appropriate SDK error type */ static classify(error: unknown, operation?: string): SDKError; /** * Check if an error is retryable */ static isRetryable(error: unknown): boolean; /** * Get retry delay for retryable errors */ static getRetryDelay(attempt: number, error?: SDKError): number; /** * Create a user-friendly error message */ static getUserMessage(error: unknown): string; } /** * Utility decorator for automatic error handling */ export declare function handleErrors(context?: string): (target: any, propertyKey: string, descriptor: PropertyDescriptor) => PropertyDescriptor; //# sourceMappingURL=error-handling.d.ts.map