Exception: Telnyx::Lib::WebSocket::WebSocketError

Inherits:
Errors::Error
  • Object
show all
Defined in:
lib/telnyx/lib/websocket/websocket_error.rb

Overview

Error class for WebSocket-related errors in STT/TTS streaming.

This error is raised when WebSocket connections encounter issues, including connection failures, message parsing errors, and server-side error events.

Example usage:

ws.on(:error) do |error|
  puts "WebSocket error: #{error.message}"
  puts "Server error: #{error.error}" if error.error
end

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(message, error: nil, cause: nil) ⇒ WebSocketError

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns a new instance of WebSocketError.

Parameters:

  • message (String)

    Human-readable error message

  • error (Hash, nil) (defaults to: nil)

    Server error event data

  • cause (StandardError, nil) (defaults to: nil)

    The underlying exception that caused this error



31
32
33
34
35
# File 'lib/telnyx/lib/websocket/websocket_error.rb', line 31

def initialize(message, error: nil, cause: nil)
  @error = error
  @cause = cause
  super(message)
end

Instance Attribute Details

#causeStandardError? (readonly)

Returns The underlying cause of this error.

Returns:

  • (StandardError, nil)

    The underlying cause of this error



24
25
26
# File 'lib/telnyx/lib/websocket/websocket_error.rb', line 24

def cause
  @cause
end

#errorHash? (readonly)

Returns The error data sent by the server in an error event.

Returns:

  • (Hash, nil)

    The error data sent by the server in an error event



21
22
23
# File 'lib/telnyx/lib/websocket/websocket_error.rb', line 21

def error
  @error
end