Class: OpenC3::JsonRpcErrorResponse

Inherits:
JsonRpcResponse show all
Defined in:
lib/openc3/io/json_rpc.rb

Overview

Represents a JSON Remote Procedure Call Error Response

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from JsonRpcResponse

from_json

Methods inherited from JsonRpc

#<=>, #as_json, #to_json

Constructor Details

#initialize(error, id) ⇒ JsonRpcErrorResponse

Returns a new instance of JsonRpcErrorResponse.

Parameters:

  • error (JsonRpcError)

    The error object

  • id (Integer)

    The identifier which will be matched to the request



358
359
360
361
# File 'lib/openc3/io/json_rpc.rb', line 358

def initialize(error, id)
  super(id)
  @hash['error'.freeze] = error
end

Class Method Details

.from_hash(hash) ⇒ JsonRpcErrorResponse

Creates a JsonRpcErrorResponse object from a Hash

Parameters:

  • hash (Hash)

    Hash containing the following keys: error and id

Returns:



372
373
374
# File 'lib/openc3/io/json_rpc.rb', line 372

def self.from_hash(hash)
  self.new(JsonRpcError.from_hash(hash['error'.freeze]), hash['id'.freeze])
end

Instance Method Details

#errorJsonRpcError

Returns The error object.

Returns:



364
365
366
# File 'lib/openc3/io/json_rpc.rb', line 364

def error
  @hash['error'.freeze]
end