From 29e7674e56bf2b829bba22def2760d034a76e788 Mon Sep 17 00:00:00 2001 From: Sadie Powell Date: Mon, 11 Mar 2024 13:53:05 +0000 Subject: 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. --- modules/protocol/plexus.cpp | 22 +++++----------------- 1 file changed, 5 insertions(+), 17 deletions(-) (limited to 'modules/protocol/plexus.cpp') 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 &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(params[2]); - } - catch (const ConvertException &) - { - ts = Anope::CurTime; - } - + auto ts = Anope::Convert(params[2], Anope::CurTime); NickAlias *na = NULL; - try - { - if (params[8].is_pos_number_only() && convertTo(params[8]) == ts) - na = NickAlias::Find(params[0]); - } - catch (const ConvertException &) { } + if (Anope::Convert(params[8], 0) == ts) + na = NickAlias::Find(params[0]); + if (params[8] != "0" && !na) na = NickAlias::Find(params[8]); -- cgit