mirror of
https://github.com/open-source-parsers/jsoncpp.git
synced 2025-10-18 11:38:59 +02:00
Fix JSON_USE_EXCEPTION=0 use case
This patch fixes the JSON_USE_EXCEPTION flag. Currently, due to the throwRuntimeError and throwLogicError methods implemented in json_value, even if JSON_USE_EXCEPTION is set to 0 jsoncpp will still throw. This breaks integration into projects with -fno-exceptions set, such as Chromium.
This commit is contained in:

committed by
Christopher Dunn

parent
5b91551f39
commit
83cc92161b
@@ -226,6 +226,7 @@ static inline void releaseStringValue(char* value, unsigned) { free(value); }
|
||||
|
||||
namespace Json {
|
||||
|
||||
#if JSON_USE_EXCEPTION
|
||||
Exception::Exception(String msg) : msg_(std::move(msg)) {}
|
||||
Exception::~Exception() JSONCPP_NOEXCEPT {}
|
||||
char const* Exception::what() const JSONCPP_NOEXCEPT { return msg_.c_str(); }
|
||||
@@ -237,6 +238,14 @@ JSONCPP_NORETURN void throwRuntimeError(String const& msg) {
|
||||
JSONCPP_NORETURN void throwLogicError(String const& msg) {
|
||||
throw LogicError(msg);
|
||||
}
|
||||
# else // !JSON_USE_EXCEPTION
|
||||
JSONCPP_NORETURN void throwRuntimeError(String const& msg) {
|
||||
abort();
|
||||
}
|
||||
JSONCPP_NORETURN void throwLogicError(String const& msg) {
|
||||
abort();
|
||||
}
|
||||
#endif
|
||||
|
||||
// //////////////////////////////////////////////////////////////////
|
||||
// //////////////////////////////////////////////////////////////////
|
||||
|
Reference in New Issue
Block a user