summaryrefslogtreecommitdiff
path: root/include/modules
diff options
context:
space:
mode:
authorSadie Powell <sadie@witchery.services>2025-02-14 20:33:13 +0000
committerSadie Powell <sadie@witchery.services>2025-02-14 20:54:06 +0000
commit420f83bbbfd3bd99d9c099d61d647cc14039d55f (patch)
tree115782ae78b734c9913f7e808770cc90b3f5b6f2 /include/modules
parent84b0859e8dec22a03fa42b822146d7666058c557 (diff)
Use RPC error responses correctly.
Diffstat (limited to 'include/modules')
-rw-r--r--include/modules/rpc.h22
1 files changed, 19 insertions, 3 deletions
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<std::pair<int64_t, Anope::string>> error;
std::map<Anope::string, Anope::string> replies;
public:
Anope::string name;
Anope::string id;
std::deque<Anope::string> 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; }
};