WebsockexNova.Gun.ConnectionWrapper.ErrorHandler (WebsockexNova v0.1.0)
View SourceStandardized error handling for the Gun ConnectionWrapper.
This module provides consistent error handling patterns for different types of errors encountered in the ConnectionWrapper. It ensures that:
- Errors are logged with appropriate context
- State is properly updated with error information
- Streams are cleaned up as needed
- Callbacks are notified with consistent error messages
- Proper return values are maintained
Summary
Functions
Handles async error response in handle_info callbacks.
Handles Gun-related connection errors.
Handles stream-related errors.
Handles transition errors when state machine transitions fail.
Handles wait_for_websocket_upgrade errors.
Functions
@spec handle_async_error( reference() | nil, term(), WebsockexNova.Gun.ConnectionState.t() ) :: {:noreply, WebsockexNova.Gun.ConnectionState.t()}
Handles async error response in handle_info callbacks.
Parameters
stream_ref
- Reference to the stream with the error (or nil)reason
- The error reasonstate
- Current connection state
Returns
{:noreply, updated_state}
- For asynchronous contexts
@spec handle_connection_error(term(), WebsockexNova.Gun.ConnectionState.t()) :: {:reply, {:error, term()}, WebsockexNova.Gun.ConnectionState.t()}
Handles Gun-related connection errors.
Parameters
reason
- The error reasonstate
- Current connection state
Returns
{:reply, {:error, reason}, state}
- For synchronous contexts
@spec handle_stream_error(reference(), term(), WebsockexNova.Gun.ConnectionState.t()) :: {:reply, {:error, term()}, WebsockexNova.Gun.ConnectionState.t()}
Handles stream-related errors.
Parameters
stream_ref
- Reference to the stream with the errorreason
- The error reasonstate
- Current connection state
Returns
{:reply, {:error, reason}, state}
- For synchronous contexts
@spec handle_transition_error( atom(), atom(), term(), WebsockexNova.Gun.ConnectionState.t() ) :: {:noreply, WebsockexNova.Gun.ConnectionState.t()}
Handles transition errors when state machine transitions fail.
Parameters
current_state
- Current state nametarget_state
- Target state namereason
- The error reasonstate
- Current connection state
Returns
{:noreply, state}
- For asynchronous contexts
@spec handle_upgrade_error(reference(), term(), WebsockexNova.Gun.ConnectionState.t()) :: {:reply, {:error, term()}, WebsockexNova.Gun.ConnectionState.t()}
Handles wait_for_websocket_upgrade errors.
Parameters
stream_ref
- Reference to the stream with the errorreason
- The error reasonstate
- Current connection state
Returns
{:reply, {:error, reason}, state}
- For synchronous contexts