Exception: SecApi::ReconnectionError

Inherits:
NetworkError show all
Defined in:
lib/sec_api/errors/reconnection_error.rb

Overview

Raised when WebSocket reconnection fails after maximum attempts.

This is a TransientError (the underlying cause was likely temporary) but after exhausting retries, we give up and surface to the caller.

Examples:

Handling reconnection failure

begin
  client.stream.subscribe { |f| process(f) }
rescue SecApi::ReconnectionError => e
  logger.error("Stream failed permanently", attempts: e.attempts)
  # Fallback to polling via Query API
end

Instance Attribute Summary collapse

Attributes inherited from Error

#request_id

Instance Method Summary collapse

Constructor Details

#initialize(message:, attempts:, downtime_seconds:, request_id: nil) ⇒ ReconnectionError

Returns a new instance of ReconnectionError.

Parameters:

  • message (String)

    Error message

  • attempts (Integer)

    Number of reconnection attempts made

  • downtime_seconds (Float)

    Total downtime in seconds

  • request_id (String, nil) (defaults to: nil)

    Request correlation ID (optional, WebSocket context may not have one)



28
29
30
31
32
# File 'lib/sec_api/errors/reconnection_error.rb', line 28

def initialize(message:, attempts:, downtime_seconds:, request_id: nil)
  @attempts = attempts
  @downtime_seconds = downtime_seconds
  super(message, request_id: request_id)
end

Instance Attribute Details

#attemptsInteger (readonly)

Returns Number of reconnection attempts made.

Returns:

  • (Integer)

    Number of reconnection attempts made



19
20
21
# File 'lib/sec_api/errors/reconnection_error.rb', line 19

def attempts
  @attempts
end

#downtime_secondsFloat (readonly)

Returns Total downtime in seconds.

Returns:

  • (Float)

    Total downtime in seconds



22
23
24
# File 'lib/sec_api/errors/reconnection_error.rb', line 22

def downtime_seconds
  @downtime_seconds
end