1
0
mirror of https://github.com/anope/anope.git synced 2026-07-01 19:26:40 +02:00

Added a ConvertException to be thrown when convertTo fails

This commit is contained in:
Adam
2010-12-29 20:19:37 -05:00
parent a36f14c1bf
commit d36e53f702
3 changed files with 13 additions and 5 deletions
+11 -3
View File
@@ -357,12 +357,20 @@ template<typename T, size_t Size = 32> class Flags
/*************************************************************************/
class ConvertException : public CoreException
{
public:
ConvertException(const Anope::string &reason = "") : CoreException(reason) { }
virtual ~ConvertException() throw() { }
};
template<typename T> inline Anope::string stringify(const T &x)
{
std::ostringstream stream;
if (!(stream << x))
throw CoreException("Stringify fail");
throw ConvertException("Stringify fail");
return stream.str();
}
@@ -374,11 +382,11 @@ template<typename T> inline void convert(const Anope::string &s, T &x, Anope::st
char c;
bool res = i >> x;
if (!res)
throw CoreException("Convert fail");
throw ConvertException("Convert fail");
if (failIfLeftoverChars)
{
if (i.get(c))
throw CoreException("Convert fail");
throw ConvertException("Convert fail");
}
else
{
+1 -1
View File
@@ -977,7 +977,7 @@ bool ChannelModeFlood::IsValid(const Anope::string &value) const
if (value[0] != ':' && convertTo<unsigned>(value[0] == '*' ? value.substr(1) : value, rest, false) > 0 && rest[0] == ':' && rest.length() > 1 && convertTo<unsigned>(rest.substr(1), rest, false) > 0 && rest.empty())
return true;
}
catch (const CoreException &) { } // convertTo fail
catch (const ConvertException &) { }
/* '['<number><1 letter>[optional: '#'+1 letter],[next..]']'':'<number> */
size_t end_bracket = value.find(']', 1);
+1 -1
View File
@@ -228,7 +228,7 @@ time_t dotime(const Anope::string &s)
}
}
}
catch (const CoreException &) { }
catch (const ConvertException &) { }
return 0;
}