Exception: CarrotRpc::Error
- Inherits:
-
StandardError
- Object
- StandardError
- CarrotRpc::Error
- Defined in:
- lib/carrot_rpc/error.rb
Overview
Error raised by an RpcServer method to signal that a JSON RPC 2.0 Response Error object should be the reply.
Defined Under Namespace
Modules: Code
Instance Attribute Summary collapse
-
#code ⇒ Integer
readonly
A Number that indicates the error type that occurred.
-
#data ⇒ Object?
readonly
A Primitive or Structured value that contains additional information about the error.
Instance Method Summary collapse
-
#initialize(code:, message:, data: nil) ⇒ Error
constructor
A new instance of Error.
-
#serialized_message ⇒ Hash{code: String, message: String}, Hash{code: String, data: Object, message: String}
A properly formatted JSON RPC Error object.
Constructor Details
#initialize(code:, message:, data: nil) ⇒ Error
Returns a new instance of Error.
22 23 24 25 26 |
# File 'lib/carrot_rpc/error.rb', line 22 def initialize(code:, message:, data: nil) @code = code @data = data super() end |
Instance Attribute Details
#code ⇒ Integer (readonly)
Returns A Number that indicates the error type that occurred. Some codes are predefined.
8 9 10 |
# File 'lib/carrot_rpc/error.rb', line 8 def code @code end |
#data ⇒ Object? (readonly)
Returns A Primitive or Structured value that contains additional information about the error. This may be omitted. The value of this member is defined by the Server (e.g. detailed error information, nested errors etc.).
13 14 15 |
# File 'lib/carrot_rpc/error.rb', line 13 def data @data end |
Instance Method Details
#serialized_message ⇒ Hash{code: String, message: String}, Hash{code: String, data: Object, message: String}
A properly formatted JSON RPC Error object.
31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/carrot_rpc/error.rb', line 31 def serialized = { code: code, message: } if data serialized[:data] = data end serialized end |