Skip to content

Commit 1b41d8b

Browse files
committed
CBD-6348: [BP] Prepare for nlohmann::json upgrade
nlohmann::json version 3.10.0 introduce a context parameter to the exception. Change-Id: Iabc6009bba333bd301f9bec3c46cc21e717fe779 Reviewed-on: https://review.couchbase.org/c/kv_engine/+/234676 Tested-by: Trond Norbye <[email protected]> Reviewed-by: Paolo Cocchi <[email protected]> Well-Formed: Restriction Checker
1 parent a89aa3a commit 1b41d8b

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

utilities/json_utilities.h

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,17 +16,21 @@
1616

1717
namespace cb {
1818

19-
/// The nlohmann exception code for incorrect types
20-
const int nlohmannExceptionTypeCode = 302;
21-
2219
/**
2320
* Helper function for throwing nlohmann incorrect type exceptions. Useful
2421
* for when we want to throw exception of a consistent type.
2522
*
2623
* @param msg the error message to be printed
2724
*/
2825
[[noreturn]] inline void throwJsonTypeError(const std::string& msg) {
26+
const int nlohmannExceptionTypeCode = 302;
27+
#if NLOHMANN_JSON_VERSION_MAJOR == 3 && NLOHMANN_JSON_VERSION_MINOR < 10
28+
/// The nlohmann exception code for incorrect types
2929
throw nlohmann::detail::type_error::create(nlohmannExceptionTypeCode, msg);
30+
#else
31+
throw nlohmann::detail::type_error::create(
32+
nlohmannExceptionTypeCode, msg, nullptr);
33+
#endif
3034
}
3135

3236
/**

0 commit comments

Comments
 (0)