diff options
author | Sadie Powell <sadie@witchery.services> | 2025-02-20 14:33:40 +0000 |
---|---|---|
committer | Sadie Powell <sadie@witchery.services> | 2025-02-20 14:57:22 +0000 |
commit | 5420f4858052bd00d86b19380755ed8eec5d2770 (patch) | |
tree | 837061a1b8448ccde5c5f6c684b2b8fdba785fac /modules/rpc/jsonrpc.cpp | |
parent | 5967bf4176dd92b29bb0bd7094755e0dac495e68 (diff) |
Use an enum for standard RPC error codes.
Diffstat (limited to 'modules/rpc/jsonrpc.cpp')
-rw-r--r-- | modules/rpc/jsonrpc.cpp | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/modules/rpc/jsonrpc.cpp b/modules/rpc/jsonrpc.cpp index 1442115b7..ab7617c4d 100644 --- a/modules/rpc/jsonrpc.cpp +++ b/modules/rpc/jsonrpc.cpp @@ -123,7 +123,7 @@ public: auto *doc = yyjson_read(message.content.c_str(), message.content.length(), YYJSON_READ_ALLOW_TRAILING_COMMAS | YYJSON_READ_ALLOW_INVALID_UNICODE); if (!doc) { - SendError(reply, -32700, "JSON parse error", ""); + SendError(reply, RPC::ERR_PARSE_ERROR, "JSON parse error", ""); return true; } @@ -132,7 +132,7 @@ public: { // TODO: handle an array of JSON-RPC requests yyjson_doc_free(doc); - SendError(reply, -32600, "Wrong JSON root element", ""); + SendError(reply, RPC::ERR_INVALID_REQUEST, "Wrong JSON root element", ""); return true; } @@ -141,7 +141,7 @@ public: if (!jsonrpc.empty() && jsonrpc != "2.0") { yyjson_doc_free(doc); - SendError(reply, -32600, "Unsupported JSON-RPC version", id); + SendError(reply, RPC::ERR_INVALID_REQUEST, "Unsupported JSON-RPC version", id); return true; } @@ -163,7 +163,7 @@ public: auto event = this->events.find(request.name); if (event == this->events.end()) { - SendError(reply, -32601, "Method not found", id); + SendError(reply, RPC::ERR_METHOD_NOT_FOUND, "Method not found", id); return true; } |