File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -37,21 +37,36 @@ namespace Json {
3737 *
3838 * We use nothing but these internally. Of course, STL can throw others.
3939 */
40- class JSON_API Exception;
40+ class JSON_API Exception : public std::exception {
41+ public:
42+ Exception (std::string const & msg);
43+ virtual ~Exception () throw ();
44+ virtual char const * what () const throw();
45+ protected:
46+ std::string const msg_;
47+ };
48+
4149/* * Exceptions which the user cannot easily avoid.
4250 *
4351 * E.g. out-of-memory (when we use malloc), stack-overflow, malicious input
4452 *
4553 * \remark derived from Json::Exception
4654 */
47- class JSON_API RuntimeError;
55+ class JSON_API RuntimeError : public Exception {
56+ public:
57+ RuntimeError (std::string const & msg);
58+ };
59+
4860/* * Exceptions thrown by JSON_ASSERT/JSON_FAIL macros.
4961 *
5062 * These are precondition-violations (user bugs) and internal errors (our bugs).
5163 *
5264 * \remark derived from Json::Exception
5365 */
54- class JSON_API LogicError;
66+ class JSON_API LogicError : public Exception {
67+ public:
68+ LogicError (std::string const & msg);
69+ };
5570
5671// / used internally
5772void throwRuntimeError (std::string const & msg);
Original file line number Diff line number Diff line change @@ -152,23 +152,6 @@ static inline void releaseStringValue(char* value) { free(value); }
152152
153153namespace Json {
154154
155- class JSON_API Exception : public std::exception {
156- public:
157- Exception (std::string const & msg);
158- virtual ~Exception () throw ();
159- virtual char const * what () const throw();
160- protected:
161- std::string const msg_;
162- };
163- class JSON_API RuntimeError : public Exception {
164- public:
165- RuntimeError (std::string const & msg);
166- };
167- class JSON_API LogicError : public Exception {
168- public:
169- LogicError (std::string const & msg);
170- };
171-
172155Exception::Exception (std::string const & msg)
173156 : msg_(msg)
174157{}
You can’t perform that action at this time.
0 commit comments