Class: JSONRPCOverMQTT::JSONRPC::ErrorResponse
- Inherits:
-
Object
- Object
- JSONRPCOverMQTT::JSONRPC::ErrorResponse
- Defined in:
- lib/json_rpc_over_mqtt_example/json_rpc/error_response.rb
Constant Summary collapse
- METHOD_NOT_FOUND =
{code: "-32601", message: "Method not found"}
- PARSE_ERROR =
{code: "-32602", message: "JSON parse error"}
Class Method Summary collapse
- .generate_response(json_rpc_id, error_response) ⇒ Object
- .method_not_found(json_rpc_id) ⇒ Object
- .parse_error ⇒ Object
Class Method Details
.generate_response(json_rpc_id, error_response) ⇒ Object
9 10 11 12 13 14 15 |
# File 'lib/json_rpc_over_mqtt_example/json_rpc/error_response.rb', line 9 def self.generate_response(json_rpc_id, error_response) ::JSON.generate({ jsonrpc: VERSION, id: json_rpc_id, error: error_response }) end |
.method_not_found(json_rpc_id) ⇒ Object
17 18 19 |
# File 'lib/json_rpc_over_mqtt_example/json_rpc/error_response.rb', line 17 def self.method_not_found(json_rpc_id) generate_response(json_rpc_id, METHOD_NOT_FOUND) end |
.parse_error ⇒ Object
21 22 23 |
# File 'lib/json_rpc_over_mqtt_example/json_rpc/error_response.rb', line 21 def self.parse_error generate_response(nil, PARSE_ERROR) end |