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. --- src/socketengines/epoll.cpp | 2 +- src/socketengines/poll.cpp | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) (limited to 'src/socketengines') diff --git a/src/socketengines/epoll.cpp b/src/socketengines/epoll.cpp index e67745096..eb70de630 100644 --- a/src/socketengines/epoll.cpp +++ b/src/socketengines/epoll.cpp @@ -67,7 +67,7 @@ void SocketEngine::Change(Socket *s, bool set, SocketFlag flag) return; if (epoll_ctl(EngineHandle, mod, ev.data.fd, &ev) == -1) - throw SocketException("Unable to epoll_ctl() fd " + stringify(ev.data.fd) + " to epoll: " + Anope::LastError()); + throw SocketException("Unable to epoll_ctl() fd " + Anope::ToString(ev.data.fd) + " to epoll: " + Anope::LastError()); } void SocketEngine::Process() diff --git a/src/socketengines/poll.cpp b/src/socketengines/poll.cpp index e9a81933b..feeac5967 100644 --- a/src/socketengines/poll.cpp +++ b/src/socketengines/poll.cpp @@ -71,7 +71,7 @@ void SocketEngine::Change(Socket *s, bool set, SocketFlag flag) { std::map::iterator pos = socket_positions.find(s->GetFD()); if (pos == socket_positions.end()) - throw SocketException("Unable to remove fd " + stringify(s->GetFD()) + " from poll, it does not exist?"); + throw SocketException("Unable to remove fd " + Anope::ToString(s->GetFD()) + " from poll, it does not exist?"); if (pos->second != events.size() - 1) { @@ -90,7 +90,7 @@ void SocketEngine::Change(Socket *s, bool set, SocketFlag flag) { std::map::iterator pos = socket_positions.find(s->GetFD()); if (pos == socket_positions.end()) - throw SocketException("Unable to modify fd " + stringify(s->GetFD()) + " in poll, it does not exist?"); + throw SocketException("Unable to modify fd " + Anope::ToString(s->GetFD()) + " in poll, it does not exist?"); pollfd &ev = events[pos->second]; ev.events = (s->flags[SF_READABLE] ? POLLIN : 0) | (s->flags[SF_WRITABLE] ? POLLOUT : 0); -- cgit