Class: OpenC3::JsonRpcError
- Defined in:
- lib/openc3/io/json_rpc.rb
Overview
Represents a JSON Remote Procedure Call Error
Defined Under Namespace
Classes: ErrorCode
Class Method Summary collapse
-
.from_hash(hash) ⇒ JsonRpcError
Creates a JsonRpcError object from a Hash.
Instance Method Summary collapse
-
#code ⇒ Integer
The error type that occurred.
-
#data ⇒ Hash
Additional information about the error.
-
#initialize(code, message, data = nil) ⇒ JsonRpcError
constructor
A new instance of JsonRpcError.
-
#message ⇒ String
A short description of the error.
Methods inherited from JsonRpc
Constructor Details
#initialize(code, message, data = nil) ⇒ JsonRpcError
Returns a new instance of JsonRpcError.
398 399 400 401 402 403 |
# File 'lib/openc3/io/json_rpc.rb', line 398 def initialize(code, , data = nil) super() @hash['code'] = code @hash['message'] = @hash['data'] = data end |
Class Method Details
.from_hash(hash) ⇒ JsonRpcError
Creates a JsonRpcError object from a Hash
425 426 427 428 429 430 431 |
# File 'lib/openc3/io/json_rpc.rb', line 425 def self.from_hash(hash) if hash['code'] and (hash['code'].to_i == hash['code']) and hash['message'] self.new(hash['code'], hash['message'], hash['data']) else raise "Invalid JSON-RPC 2.0 Error\n#{hash.inspect}\n" end end |
Instance Method Details
#code ⇒ Integer
Returns The error type that occurred.
406 407 408 |
# File 'lib/openc3/io/json_rpc.rb', line 406 def code @hash['code'] end |
#data ⇒ Hash
Returns Additional information about the error.
416 417 418 |
# File 'lib/openc3/io/json_rpc.rb', line 416 def data @hash['data'] end |
#message ⇒ String
Returns A short description of the error.
411 412 413 |
# File 'lib/openc3/io/json_rpc.rb', line 411 def @hash['message'] end |