Exception: Solace::Errors::ParseError

Inherits:
Error
  • Object
show all
Defined in:
lib/solace/errors/parse_error.rb

Overview

Raised when parsing or deserializing data fails.

This error is raised when the gem encounters data that cannot be properly parsed or deserialized, such as malformed JSON responses from the RPC node, invalid binary data, or unexpected data structures. This typically indicates either a bug in the gem or an incompatibility with the RPC node’s response format.

Examples:

Handling parse errors

begin
  transaction = Solace::Transaction.deserialize(binary_data)
rescue Solace::Errors::ParseError => e
  puts "Failed to parse transaction: #{e.message}"
end

Since:

  • 0.0.1

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(message, body:) ⇒ ParseError

Returns a new instance of ParseError.

Parameters:

  • message (String)

    The error message

  • body (Object)

    The response body

Since:

  • 0.0.1



25
26
27
28
# File 'lib/solace/errors/parse_error.rb', line 25

def initialize(message, body:)
  super(message)
  @body = body
end

Instance Attribute Details

#bodyObject (readonly)

Since:

  • 0.0.1



21
22
23
# File 'lib/solace/errors/parse_error.rb', line 21

def body
  @body
end

Class Method Details

.format_response(error, response) ⇒ Solace::Errors::ParseError

Formats a response to an error

Parameters:

  • error (JSON::ParserError)

    The JSON-RPC error

  • response (Object)

    The response from the RPC

Returns:

Since:

  • 0.0.1



35
36
37
# File 'lib/solace/errors/parse_error.rb', line 35

def self.format_response(error, response)
  new("Invalid JSON from RPC: #{error.message}", body: response.body)
end