diff options
| author | Adam <Adam@anope.org> | 2010-12-29 20:19:37 -0500 |
|---|---|---|
| committer | Adam <Adam@anope.org> | 2010-12-29 20:19:37 -0500 |
| commit | d36e53f702f6f166e862c88dd2399bef91e9d1d5 (patch) | |
| tree | 310a543eeb0af34f8fc09c38dce940824921d9b3 /include | |
| parent | a36f14c1bfca63ba744ab310af775cf6d5b81179 (diff) | |
Added a ConvertException to be thrown when convertTo fails
Diffstat (limited to 'include')
| -rw-r--r-- | include/services.h | 14 |
1 files changed, 11 insertions, 3 deletions
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<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 { |
