Skip to main content
New protocol version released: This page may contain outdated information.
Build resilient applications with the HAIP SDK’s comprehensive error handling system. Learn how to implement proper error recovery, debugging strategies, and graceful degradation for production-ready HAIP applications.

Error Types

HAIPError Hierarchy

The SDK defines a hierarchy of error types for different scenarios:

Common Error Codes

Error CodeDescriptionRecovery Action
CONNECTION_FAILEDConnection to server failedRetry with exponential backoff
AUTHENTICATION_FAILEDJWT token invalid or expiredRefresh token and reconnect
FLOW_CONTROLNo credits available for sendingWait for flow update or request credits
PROTOCOL_ERRORInvalid message format or sequenceReset connection
TIMEOUTOperation timed outRetry with longer timeout
RATE_LIMITEDToo many requestsImplement rate limiting
SERVER_ERRORServer-side errorRetry with exponential backoff

Basic Error Handling

Event-Based Error Handling

Try-Catch Error Handling

Advanced Error Handling

Error Recovery Strategies

Circuit Breaker Pattern

Connection Error Handling

Automatic Reconnection

Connection Health Monitoring

Message Error Handling

Message Retry Logic

Error Logging and Monitoring

Structured Error Logging

Error Metrics Collection

Testing Error Handling

Error Simulation Testing

Best Practices

Error Handling Checklist

  1. Always handle connection errors
  2. Implement retry logic for transient errors
  3. Monitor error rates and patterns
  4. Provide user feedback for errors
  5. Implement graceful degradation

Error Recovery Patterns

Next Steps

Client API

Learn about the client interface and methods.

Examples

See practical examples of error handling.

Flow Control

Understand flow control and back-pressure management.

API Reference

Full API reference documentation.