diff options
author | Sadie Powell <sadie@witchery.services> | 2024-03-11 13:53:05 +0000 |
---|---|---|
committer | Sadie Powell <sadie@witchery.services> | 2024-03-11 19:17:29 +0000 |
commit | 29e7674e56bf2b829bba22def2760d034a76e788 (patch) | |
tree | f40049ba995b03dd7c510d88f9f19db2d2e65a2e /modules/memoserv/ms_set.cpp | |
parent | e2df7d4d01f8fdb41c49ce8efc462cab005e7d5c (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/memoserv/ms_set.cpp')
-rw-r--r-- | modules/memoserv/ms_set.cpp | 16 |
1 files changed, 4 insertions, 12 deletions
diff --git a/modules/memoserv/ms_set.cpp b/modules/memoserv/ms_set.cpp index 83b28fb20..54ad7c252 100644 --- a/modules/memoserv/ms_set.cpp +++ b/modules/memoserv/ms_set.cpp @@ -135,12 +135,8 @@ private: else nc->Shrink<bool>("MEMO_HARDMAX"); } - limit = -1; - try - { - limit = convertTo<int16_t>(p1); - } - catch (const ConvertException &) { } + + limit = Anope::Convert<int16_t>(p1, -1); } else { @@ -160,12 +156,8 @@ private: return; } int max_memos = Config->GetModule("memoserv")->Get<int>("maxmemos"); - limit = -1; - try - { - limit = convertTo<int16_t>(p1); - } - catch (const ConvertException &) { } + limit = Anope::Convert<int16_t>(p1, -1); + /* The first character is a digit, but we could still go negative * from overflow... watch out! */ if (limit < 0 || (max_memos > 0 && limit > max_memos)) |