summaryrefslogtreecommitdiff
path: root/src/config.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 /src/config.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 'src/config.cpp')
-rw-r--r--src/config.cpp16
1 files changed, 8 insertions, 8 deletions
diff --git a/src/config.cpp b/src/config.cpp
index ca36bea7d..6a8380464 100644
--- a/src/config.cpp
+++ b/src/config.cpp
@@ -824,12 +824,12 @@ void Conf::LoadConf(File &file)
if (block_stack.empty() || itemname.empty())
{
file.Close();
- throw ConfigException("Unexpected quoted string: " + file.GetName() + ":" + stringify(linenumber));
+ throw ConfigException("Unexpected quoted string: " + file.GetName() + ":" + Anope::ToString(linenumber));
}
if (in_word || !wordbuffer.empty())
{
file.Close();
- throw ConfigException("Unexpected quoted string (prior unhandled words): " + file.GetName() + ":" + stringify(linenumber));
+ throw ConfigException("Unexpected quoted string (prior unhandled words): " + file.GetName() + ":" + Anope::ToString(linenumber));
}
in_quote = in_word = true;
}
@@ -838,13 +838,13 @@ void Conf::LoadConf(File &file)
if (block_stack.empty())
{
file.Close();
- throw ConfigException("Config item outside of section (or stray '='): " + file.GetName() + ":" + stringify(linenumber));
+ throw ConfigException("Config item outside of section (or stray '='): " + file.GetName() + ":" + Anope::ToString(linenumber));
}
if (!itemname.empty() || wordbuffer.empty())
{
file.Close();
- throw ConfigException("Stray '=' sign or item without value: " + file.GetName() + ":" + stringify(linenumber));
+ throw ConfigException("Stray '=' sign or item without value: " + file.GetName() + ":" + Anope::ToString(linenumber));
}
in_word = false;
@@ -891,7 +891,7 @@ void Conf::LoadConf(File &file)
if (!in_word && !wordbuffer.empty())
{
file.Close();
- throw ConfigException("Unexpected word: " + file.GetName() + ":" + stringify(linenumber));
+ throw ConfigException("Unexpected word: " + file.GetName() + ":" + Anope::ToString(linenumber));
}
wordbuffer += ch;
in_word = true;
@@ -918,7 +918,7 @@ void Conf::LoadConf(File &file)
if (block_stack.empty())
{
file.Close();
- throw ConfigException("Stray ';' outside of block: " + file.GetName() + ":" + stringify(linenumber));
+ throw ConfigException("Stray ';' outside of block: " + file.GetName() + ":" + Anope::ToString(linenumber));
}
Block *b = block_stack.top();
@@ -949,7 +949,7 @@ void Conf::LoadConf(File &file)
if (block_stack.empty())
{
file.Close();
- throw ConfigException("Stray '}': " + file.GetName() + ":" + stringify(linenumber));
+ throw ConfigException("Stray '}': " + file.GetName() + ":" + Anope::ToString(linenumber));
}
block_stack.pop();
@@ -969,7 +969,7 @@ void Conf::LoadConf(File &file)
if (!block_stack.empty())
{
if (block_stack.top())
- throw ConfigException("Unterminated block at end of file: " + file.GetName() + ". Block was opened on line " + stringify(block_stack.top()->linenum));
+ throw ConfigException("Unterminated block at end of file: " + file.GetName() + ". Block was opened on line " + Anope::ToString(block_stack.top()->linenum));
else
throw ConfigException("Unterminated commented block at end of file: " + file.GetName());
}