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



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

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:



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

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:



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

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