Exceptions declared in header
resolves #272
diff --git a/include/json/value.h b/include/json/value.h
index 68fc163..8e996ae 100644
--- a/include/json/value.h
+++ b/include/json/value.h
@@ -37,21 +37,36 @@
*
* We use nothing but these internally. Of course, STL can throw others.
*/
-class JSON_API Exception;
+class JSON_API Exception : public std::exception {
+public:
+ Exception(std::string const& msg);
+ virtual ~Exception() throw();
+ virtual char const* what() const throw();
+protected:
+ std::string const msg_;
+};
+
/** Exceptions which the user cannot easily avoid.
*
* E.g. out-of-memory (when we use malloc), stack-overflow, malicious input
*
* \remark derived from Json::Exception
*/
-class JSON_API RuntimeError;
+class JSON_API RuntimeError : public Exception {
+public:
+ RuntimeError(std::string const& msg);
+};
+
/** Exceptions thrown by JSON_ASSERT/JSON_FAIL macros.
*
* These are precondition-violations (user bugs) and internal errors (our bugs).
*
* \remark derived from Json::Exception
*/
-class JSON_API LogicError;
+class JSON_API LogicError : public Exception {
+public:
+ LogicError(std::string const& msg);
+};
/// used internally
void throwRuntimeError(std::string const& msg);