/** * Common Error Patterns for Adapters * * This module provides pre-configured error patterns for common error * scenarios that adapters encounter. These patterns can be used directly * or as a foundation for adapter-specific patterns. * * ## Pattern Categories * - Connection Failures: ECONNREFUSED, ENOTFOUND, ECONNRESET, DNS errors * - Timeouts: Timeout, timed out, ETIMEDOUT * - HTTP Status Errors: 4xx and 5xx status codes * - Protocol Errors: Parse errors, invalid JSON, protocol violations * - SSL/TLS Errors: Certificate validation failures * - Rate Limiting: HTTP 429, rate limit exceeded * - Network Errors: General network connectivity issues * * ## Usage * ```typescript * import { COMMON_ERROR_PATTERNS } from "@wavespec/kit/error"; * import { ErrorMapper } from "@wavespec/kit/error"; * * const mapper = new ErrorMapper({ * defaultCode: "TEST_EXECUTION_ERROR", * defaultHint: "Unexpected error" * }); * * // Add all common patterns * mapper.addPatterns(COMMON_ERROR_PATTERNS); * * // Or add specific patterns * mapper.addPattern(CONNECTION_REFUSED_PATTERN); * ``` * * ## Pattern Order * Patterns are matched in order (first match wins), so specific patterns * are defined before generic ones. This ensures precise error classification. * * @module @wavespec/kit/error */ import type { ErrorPattern } from "./types.js"; /** * Connection refused - server actively rejected connection * * Matches: ECONNREFUSED error codes, "connection refused" messages */ export declare const CONNECTION_REFUSED_PATTERN: ErrorPattern; /** * Connection reset - connection was forcibly closed by server * * Matches: ECONNRESET error codes, "connection reset" messages */ export declare const CONNECTION_RESET_PATTERN: ErrorPattern; /** * DNS resolution failed - hostname could not be resolved * * Matches: ENOTFOUND, GETADDRINFO errors */ export declare const DNS_RESOLUTION_FAILED_PATTERN: ErrorPattern; /** * Network unreachable - system cannot reach the network * * Matches: ENETUNREACH error code */ export declare const NETWORK_UNREACHABLE_PATTERN: ErrorPattern; /** * Host unreachable - specific host cannot be reached * * Matches: EHOSTUNREACH error code */ export declare const HOST_UNREACHABLE_PATTERN: ErrorPattern; /** * Generic connection error - connection failed (catch-all) * * Matches: "connection" in error message (catch-all for other connection errors) */ export declare const GENERIC_CONNECTION_ERROR_PATTERN: ErrorPattern; /** * Operation timeout - operation exceeded configured timeout * * Matches: "timeout" or "timed out" in message, ETIMEDOUT code */ export declare const OPERATION_TIMEOUT_PATTERN: ErrorPattern; /** * Request timeout - HTTP request timed out * * Matches: Headers timeout, body timeout, or general timeout */ export declare const REQUEST_TIMEOUT_PATTERN: ErrorPattern; /** * Connect timeout - connection attempt timed out * * Matches: Connection timeout messages */ export declare const CONNECT_TIMEOUT_PATTERN: ErrorPattern; /** * JSON parse error - response is not valid JSON * * Matches: SyntaxError, "JSON.parse" errors, "Unexpected token" errors */ export declare const JSON_PARSE_ERROR_PATTERN: ErrorPattern; /** * Invalid response - response missing required fields * * Matches: "invalid response", "malformed", protocol-specific errors */ export declare const INVALID_RESPONSE_PATTERN: ErrorPattern; /** * Protocol error - generic protocol violation * * Matches: "protocol", "protocol error", MCP-specific protocol errors */ export declare const PROTOCOL_ERROR_PATTERN: ErrorPattern; /** * Unexpected response type - server sent wrong type of response * * Matches: Response type mismatches, unexpected message types */ export declare const UNEXPECTED_RESPONSE_PATTERN: ErrorPattern; /** * SSL/TLS certificate validation failed * * Matches: SSL, TLS, certificate, cert errors */ export declare const SSL_CERTIFICATE_ERROR_PATTERN: ErrorPattern; /** * Certificate hostname mismatch * * Matches: "hostname", "host", "name mismatch" in SSL context */ export declare const CERTIFICATE_HOSTNAME_MISMATCH_PATTERN: ErrorPattern; /** * Certificate expired * * Matches: "expired", "validity" in SSL context */ export declare const CERTIFICATE_EXPIRED_PATTERN: ErrorPattern; /** * HTTP 400 Bad Request - invalid parameters * * Matches: "400" status code */ export declare const HTTP_400_BAD_REQUEST_PATTERN: ErrorPattern; /** * HTTP 401 Unauthorized - authentication required * * Matches: "401" status code */ export declare const HTTP_401_UNAUTHORIZED_PATTERN: ErrorPattern; /** * HTTP 403 Forbidden - authenticated but not authorized * * Matches: "403" status code */ export declare const HTTP_403_FORBIDDEN_PATTERN: ErrorPattern; /** * HTTP 404 Not Found - resource doesn't exist * * Matches: "404" status code */ export declare const HTTP_404_NOT_FOUND_PATTERN: ErrorPattern; /** * HTTP 429 Too Many Requests - rate limited * * Matches: "429" status code */ export declare const HTTP_429_RATE_LIMITED_PATTERN: ErrorPattern; /** * HTTP 500 Internal Server Error - server bug * * Matches: "500" status code */ export declare const HTTP_500_SERVER_ERROR_PATTERN: ErrorPattern; /** * HTTP 503 Service Unavailable - server temporarily down * * Matches: "502", "503", "504" status codes */ export declare const HTTP_UNAVAILABLE_PATTERN: ErrorPattern; /** * Network error - generic network connectivity issue * * Matches: "network" errors that don't match specific patterns */ export declare const NETWORK_ERROR_PATTERN: ErrorPattern; /** * EOFCONNECTIONS - end of file on socket * * Matches: EOF, FIN, connection closed by peer */ export declare const EOF_PATTERN: ErrorPattern; /** * Collection of all common error patterns * * These patterns are ordered to ensure specific patterns are matched * before generic ones (first match wins). * * Order: * 1. HTTP status codes (most specific - explicit status code checks) * 2. Timeout errors (specific timeout indicators) * 3. Connection errors * 4. Protocol errors * 5. SSL/TLS errors * 6. Network errors (most generic) * * Adapters can use this directly or create a modified list with * adapter-specific patterns added before or after these patterns. */ export declare const COMMON_ERROR_PATTERNS: ErrorPattern[]; /** * Count of common error patterns * * Useful for documentation and verification. */ export declare const COMMON_ERROR_PATTERN_COUNT: number; //# sourceMappingURL=patterns.d.ts.map