summaryrefslogtreecommitdiff
path: root/json
diff options
context:
space:
mode:
authorGlenn Smith <glenn@vector35.com>2023-09-01 00:28:41 -0400
committerAlexander Taylor <ajtaylor@fuzyll.com>2023-09-01 13:18:59 -0400
commit3a2115bcdcfbca0432afad84f4877187f72514a2 (patch)
treec33d689280b37e2c04d6f655d6ea66e4adc26fbd /json
parent9cc14bb1edbd111530ee1e936fe5e59de9450832 (diff)
Make asserts from jsoncpp more descriptive
Diffstat (limited to 'json')
-rw-r--r--json/json.h16
-rw-r--r--json/jsoncpp.cpp5
2 files changed, 13 insertions, 8 deletions
diff --git a/json/json.h b/json/json.h
index da91470a..399de6ca 100644
--- a/json/json.h
+++ b/json/json.h
@@ -502,6 +502,12 @@ public:
#pragma warning(disable : 4251)
#endif // if defined(JSONCPP_DISABLE_DLL_INTERFACE_WARNING)
+// XXX: BN: Use our exception class for extra details
+#include "../exceptions.h"
+#define JSONCPP_EXCEPTION ExceptionWithStackTrace
+// #define JSONCPP_EXCEPTION std::runtime_error
+
+
#pragma pack(push, 8)
/** \brief JSON (JavaScript Object Notation).
@@ -512,14 +518,12 @@ namespace Json {
*
* We use nothing but these internally. Of course, STL can throw others.
*/
-class JSON_API Exception : public std::exception {
+class JSON_API Exception : public JSONCPP_EXCEPTION /* BN: subclass changed */ {
public:
Exception(JSONCPP_STRING const& msg);
~Exception() JSONCPP_NOEXCEPT JSONCPP_OVERRIDE;
- char const* what() const JSONCPP_NOEXCEPT JSONCPP_OVERRIDE;
-
-protected:
- JSONCPP_STRING msg_;
+ // BN: Member removed
+ // BN: what() removed
};
/** Exceptions which the user cannot easily avoid.
@@ -2222,7 +2226,7 @@ JSON_API JSONCPP_OSTREAM& operator<<(JSONCPP_OSTREAM&, const Value& root);
#define JSON_ASSERT(condition) \
{ \
if (!(condition)) { \
- Json::throwLogicError("assert json failed"); \
+ Json::throwLogicError(#condition); \
} \
}
diff --git a/json/jsoncpp.cpp b/json/jsoncpp.cpp
index 4154200b..307cf560 100644
--- a/json/jsoncpp.cpp
+++ b/json/jsoncpp.cpp
@@ -2653,9 +2653,10 @@ static inline void releaseStringValue(char* value, unsigned) { free(value); }
namespace Json {
-Exception::Exception(JSONCPP_STRING const& msg) : msg_(msg) {}
+// BN: subclass
+Exception::Exception(JSONCPP_STRING const& msg) : JSONCPP_EXCEPTION(msg) {}
Exception::~Exception() JSONCPP_NOEXCEPT {}
-char const* Exception::what() const JSONCPP_NOEXCEPT { return msg_.c_str(); }
+// BN: removed what()
RuntimeError::RuntimeError(JSONCPP_STRING const& msg) : Exception(msg) {}
LogicError::LogicError(JSONCPP_STRING const& msg) : Exception(msg) {}
JSONCPP_NORETURN void throwRuntimeError(JSONCPP_STRING const& msg) {