]> git.tdb.fi Git - libs/core.git/blobdiff - source/strings/lexicalcast.h
Exception improvements for lexical_cast
[libs/core.git] / source / strings / lexicalcast.h
index 3bfc342a1f584e91cc218eb24b226c7a29c777da..b41654d1537a822f8a13af2d1a0616a4761d0e2f 100644 (file)
@@ -10,7 +10,7 @@ Distributed under the LGPL
 
 #include <sstream>
 #include <string>
-#include <msp/core/except.h>
+#include <stdexcept>
 #include "fmt.h"
 
 namespace Msp {
@@ -18,10 +18,19 @@ namespace Msp {
 /**
 Thrown for errors in lexical conversions
 */
-class LexicalError: public Exception
+class lexical_error: public std::runtime_error
 {
 public:
-       LexicalError(const std::string &w_): Exception(w_) { }
+       lexical_error(const std::string &w): runtime_error(w) { }
+       virtual ~lexical_error() throw() { }
+};
+
+
+class format_mismatch: public lexical_error
+{
+public:
+       format_mismatch(const std::string &w): lexical_error(w) { }
+       virtual ~format_mismatch() throw() { }
 };
 
 
@@ -101,7 +110,7 @@ void operator>>(const LexicalConverter &c, T &v)
        ss.setf(std::ios_base::fmtflags(0), std::ios_base::skipws);
        ss>>v;
        if(ss.fail() || !ss.eof())
-               throw LexicalError("Conversion failure");
+               throw lexical_error("conversion failure");
 }
 
 // The main interface to the lexical conversion machinery