From 420f83bbbfd3bd99d9c099d61d647cc14039d55f Mon Sep 17 00:00:00 2001 From: Sadie Powell Date: Fri, 14 Feb 2025 20:33:13 +0000 Subject: Use RPC error responses correctly. --- include/modules/rpc.h | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) (limited to 'include/modules') diff --git a/include/modules/rpc.h b/include/modules/rpc.h index 7171b73a8..76ecf3542 100644 --- a/include/modules/rpc.h +++ b/include/modules/rpc.h @@ -13,16 +13,32 @@ class RPCRequest final { private: + std::optional> error; std::map replies; public: Anope::string name; Anope::string id; std::deque data; - HTTPReply &r; + HTTPReply &reply; + + RPCRequest(HTTPReply &r) + : reply(r) + { + } + + inline void Error(uint64_t errcode, const Anope::string &errstr) + { + this->error.emplace(errcode, errstr); + } + + inline void Reply(const Anope::string &dname, const Anope::string &ddata) + { + this->replies.emplace(dname, ddata); + } + + inline const auto &GetError() { return this->error; } - RPCRequest(HTTPReply &_r) : r(_r) { } - inline void Reply(const Anope::string &dname, const Anope::string &ddata) { this->replies.emplace(dname, ddata); } inline const auto &GetReplies() { return this->replies; } }; -- cgit