summaryrefslogtreecommitdiff
path: root/modules/protocol/plexus.cpp
diff options
context:
space:
mode:
authorSadie Powell <sadie@witchery.services>2024-03-11 13:53:05 +0000
committerSadie Powell <sadie@witchery.services>2024-03-11 19:17:29 +0000
commit29e7674e56bf2b829bba22def2760d034a76e788 (patch)
treef40049ba995b03dd7c510d88f9f19db2d2e65a2e /modules/protocol/plexus.cpp
parente2df7d4d01f8fdb41c49ce8efc462cab005e7d5c (diff)
Replace convertTo/stringify with non-throwing alternatives.
Having these throw is terrible for ergonomics and there are loads of places where the exception was either silently ignored or not handled at all. Having a function which returns an optional and another that returns a default works a lot better imo.
Diffstat (limited to 'modules/protocol/plexus.cpp')
-rw-r--r--modules/protocol/plexus.cpp22
1 files changed, 5 insertions, 17 deletions
diff --git a/modules/protocol/plexus.cpp b/modules/protocol/plexus.cpp
index 1e5ae714b..a2282276a 100644
--- a/modules/protocol/plexus.cpp
+++ b/modules/protocol/plexus.cpp
@@ -144,7 +144,7 @@ public:
void SendModeInternal(const MessageSource &source, User *u, const Anope::string &modes, const std::vector<Anope::string> &values) override
{
auto params = values;
- params.insert(params.begin(), { "*", "SVSMODE", u->GetUID(), stringify(u->timestamp), modes });
+ params.insert(params.begin(), { "*", "SVSMODE", u->GetUID(), Anope::ToString(u->timestamp), modes });
Uplink::SendInternal({}, source, "ENCAP", params);
}
@@ -306,23 +306,11 @@ struct IRCDMessageUID final
if (ip == "0")
ip.clear();
- time_t ts;
- try
- {
- ts = convertTo<time_t>(params[2]);
- }
- catch (const ConvertException &)
- {
- ts = Anope::CurTime;
- }
-
+ auto ts = Anope::Convert<time_t>(params[2], Anope::CurTime);
NickAlias *na = NULL;
- try
- {
- if (params[8].is_pos_number_only() && convertTo<time_t>(params[8]) == ts)
- na = NickAlias::Find(params[0]);
- }
- catch (const ConvertException &) { }
+ if (Anope::Convert<time_t>(params[8], 0) == ts)
+ na = NickAlias::Find(params[0]);
+
if (params[8] != "0" && !na)
na = NickAlias::Find(params[8]);