1
0
mirror of https://github.com/anope/anope.git synced 2026-06-25 05:16:38 +02:00

try/catch-ified all instances of convertTo to keep from aborting when a user gives too large or too small a number

This commit is contained in:
Adam
2011-02-04 21:01:33 -05:00
parent faf5f3128f
commit 83556667fd
12 changed files with 236 additions and 144 deletions
+13 -6
View File
@@ -69,15 +69,22 @@ class CommandEntryMessage : public Command
source.Reply(("Entry message \002%s\002 not found on channel \002%s\002."), message.c_str(), ci->name.c_str());
else if (ci->GetExtRegular("cs_entrymsg", messages))
{
unsigned i = convertTo<unsigned>(message);
if (i > 0 && i <= messages.size())
try
{
messages.erase(messages.begin() + i - 1);
ci->Extend("cs_entrymsg", new ExtensibleItemRegular<std::vector<EntryMsg> >(messages));
source.Reply(_("Entry message \2%i\2 for \2%s\2 deleted."), i, ci->name.c_str());
unsigned i = convertTo<unsigned>(message);
if (i <= messages.size())
{
messages.erase(messages.begin() + i - 1);
ci->Extend("cs_entrymsg", new ExtensibleItemRegular<std::vector<EntryMsg> >(messages));
source.Reply(_("Entry message \2%i\2 for \2%s\2 deleted."), i, ci->name.c_str());
}
else
throw ConvertException();
}
else
catch (const ConvertException &)
{
source.Reply(_("Entry message \2%s\2 not found on channel \2%s\2."), message.c_str(), ci->name.c_str());
}
}
else
source.Reply(_("Entry message list for \2%s\2 is empty."), ci->name.c_str());