@@ -12,24 +12,21 @@ namespace jsonrpccxx {
12
12
static inline bool valid_id (const json &request) {
13
13
return has_key (request, " id" ) && (request[" id" ].is_number () || request[" id" ].is_string () || request[" id" ].is_null ());
14
14
}
15
- static inline bool valid_id_not_null (const json &request) { return has_key (request, " id" ) && (request[" id" ].is_number () || request[" id" ].is_string ());}
15
+ static inline bool valid_id_not_null (const json &request) { return has_key (request, " id" ) && (request[" id" ].is_number () || request[" id" ].is_string ()); }
16
16
17
17
class JsonRpcException : public std ::exception {
18
18
public:
19
- JsonRpcException (int code, const std::string &message) noexcept : code(code), message(message), data(nullptr ) {
20
- err = std::to_string (code) + " : " + message;
21
- }
22
- JsonRpcException (int code, const std::string &message, const json &data) noexcept : code(code), message(message), data(data) {
23
- err = std::to_string (code) + " : " + message + " , data: " + data.dump ();
24
- }
19
+ JsonRpcException (int code, const std::string &message) noexcept : code(code), message(message), data(nullptr ), err(std::to_string(code) + " : " + message) {}
20
+ JsonRpcException (int code, const std::string &message, const json &data) noexcept
21
+ : code(code), message(message), data(data), err(std::to_string(code) + " : " + message + " , data: " + data.dump()) {}
25
22
26
23
int Code () const { return code; }
27
24
const std::string &Message () const { return message; }
28
25
const json &Data () const { return data; }
29
26
30
27
const char *what () const noexcept override { return err.c_str (); }
31
28
32
- static inline JsonRpcException fromJson (const json&value) {
29
+ static inline JsonRpcException fromJson (const json &value) {
33
30
bool has_code = has_key_type (value, " code" , json::value_t ::number_integer);
34
31
bool has_message = has_key_type (value, " message" , json::value_t ::string);
35
32
bool has_data = has_key (value, " data" );
0 commit comments