mirror of
https://github.com/open-source-parsers/jsoncpp.git
synced 2025-03-04 07:27:22 +01:00
use Json::LogicError in macros
This commit is contained in:
parent
5383794cc9
commit
9376368d86
@ -18,21 +18,25 @@
|
|||||||
* for pre-condition violations and internal logic errors.
|
* for pre-condition violations and internal logic errors.
|
||||||
*/
|
*/
|
||||||
#if JSON_USE_EXCEPTION
|
#if JSON_USE_EXCEPTION
|
||||||
#include <stdexcept>
|
|
||||||
#define JSON_ASSERT(condition) \
|
// @todo <= add detail about condition in exception
|
||||||
{if (!(condition)) {throw std::logic_error( "assert json failed" );}} // @todo <= add detail about condition in exception
|
# define JSON_ASSERT(condition) \
|
||||||
#define JSON_FAIL_MESSAGE(message) \
|
{if (!(condition)) {Json::throwLogicError( "assert json failed" );}}
|
||||||
|
|
||||||
|
# define JSON_FAIL_MESSAGE(message) \
|
||||||
{ \
|
{ \
|
||||||
std::ostringstream oss; oss << message; \
|
std::ostringstream oss; oss << message; \
|
||||||
throw std::logic_error(oss.str()); \
|
Json::throwLogicError(oss.str()); \
|
||||||
|
abort(); \
|
||||||
}
|
}
|
||||||
//#define JSON_FAIL_MESSAGE(message) throw std::logic_error(message)
|
|
||||||
#else // JSON_USE_EXCEPTION
|
#else // JSON_USE_EXCEPTION
|
||||||
#define JSON_ASSERT(condition) assert(condition)
|
|
||||||
|
# define JSON_ASSERT(condition) assert(condition)
|
||||||
|
|
||||||
// The call to assert() will show the failure message in debug builds. In
|
// The call to assert() will show the failure message in debug builds. In
|
||||||
// release builds we abort, for a core-dump or debugger.
|
// release builds we abort, for a core-dump or debugger.
|
||||||
#define JSON_FAIL_MESSAGE(message) \
|
# define JSON_FAIL_MESSAGE(message) \
|
||||||
{ \
|
{ \
|
||||||
std::ostringstream oss; oss << message; \
|
std::ostringstream oss; oss << message; \
|
||||||
assert(false && oss.str().c_str()); \
|
assert(false && oss.str().c_str()); \
|
||||||
|
Loading…
x
Reference in New Issue
Block a user