Skip to content

Commit 5ea7673

Browse files
committed
Inline ctor code to initializer of JsonRpcException
1 parent daae5da commit 5ea7673

File tree

1 file changed

+5
-8
lines changed

1 file changed

+5
-8
lines changed

include/jsonrpccxx/common.hpp

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,24 +12,21 @@ namespace jsonrpccxx {
1212
static inline bool valid_id(const json &request) {
1313
return has_key(request, "id") && (request["id"].is_number() || request["id"].is_string() || request["id"].is_null());
1414
}
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()); }
1616

1717
class JsonRpcException : public std::exception {
1818
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()) {}
2522

2623
int Code() const { return code; }
2724
const std::string &Message() const { return message; }
2825
const json &Data() const { return data; }
2926

3027
const char *what() const noexcept override { return err.c_str(); }
3128

32-
static inline JsonRpcException fromJson(const json&value) {
29+
static inline JsonRpcException fromJson(const json &value) {
3330
bool has_code = has_key_type(value, "code", json::value_t::number_integer);
3431
bool has_message = has_key_type(value, "message", json::value_t::string);
3532
bool has_data = has_key(value, "data");

0 commit comments

Comments
 (0)