From d36e53f702f6f166e862c88dd2399bef91e9d1d5 Mon Sep 17 00:00:00 2001 From: Adam Date: Wed, 29 Dec 2010 20:19:37 -0500 Subject: Added a ConvertException to be thrown when convertTo fails --- include/services.h | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) (limited to 'include') diff --git a/include/services.h b/include/services.h index 5448d9170..d233da5b8 100644 --- a/include/services.h +++ b/include/services.h @@ -357,12 +357,20 @@ template class Flags /*************************************************************************/ +class ConvertException : public CoreException +{ + public: + ConvertException(const Anope::string &reason = "") : CoreException(reason) { } + + virtual ~ConvertException() throw() { } +}; + template 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 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 { -- cgit