UNPKG

@dexwox-labs/a2a-client

Version:

TypeScript client implementation for Google's Agent-to-Agent (A2A) protocol - includes HTTP/WebSocket communication, circuit breakers and error handling

40 lines 1.47 kB
/** * @module ErrorHandler * @description Utilities for handling and normalizing errors in the A2A SDK */ import { A2AError, A2AClientError, A2AServerError, A2ANetworkError, A2AValidationError, A2ATimeoutError } from './error'; export { A2AError, A2AClientError, A2AServerError, A2ANetworkError, A2AValidationError, A2ATimeoutError }; /** * Normalizes any error into an A2AError * * This utility function converts any error or exception into a standardized * A2AError object. It handles various error types including: * - Existing A2AError instances (returned as-is) * - Standard JavaScript Error objects * - Server response objects with status codes * - Any other unknown error types * * @param err - The error to normalize, can be of any type * @returns A standardized A2AError instance * * @example * ```typescript * try { * // Some operation that might fail * await fetch('https://a2a-server.example.com'); * } catch (error) { * // Normalize the error to a standard format * const normalizedError = normalizeError(error); * * // Now we can handle it consistently * console.error(`Error (${normalizedError.code}): ${normalizedError.message}`); * * // And we can check for specific error types * if (normalizedError instanceof A2ANetworkError) { * // Handle network errors specifically * } * } * ``` */ export declare function normalizeError(err: unknown): A2AError; //# sourceMappingURL=error-handler.d.ts.map