WebsockexAdapter.ErrorHandler (WebsockexAdapter v0.1.1)

View Source

Simple error handling for WebSocket connections.

Handles common error scenarios:

  • Connection errors (network failures)
  • Protocol errors (malformed frames)
  • Authentication errors
  • Timeout errors

Passes raw errors without wrapping to preserve original error information.

Summary

Functions

Categorizes errors into recoverable vs non-recoverable types.

Handles errors by returning appropriate actions.

Determines if an error is recoverable through reconnection.

Functions

categorize_error(error)

@spec categorize_error(term()) :: {:recoverable | :fatal, term()}

Categorizes errors into recoverable vs non-recoverable types.

Returns the raw error unchanged to preserve all original information.

handle_error(error)

@spec handle_error(term()) :: :reconnect | :stop

Handles errors by returning appropriate actions.

Returns either :reconnect or :stop based on error recoverability.

recoverable?(error)

@spec recoverable?(term()) :: boolean()

Determines if an error is recoverable through reconnection.