|
@@ -10,6 +10,25 @@
|
|
|
|
|
|
#define nJson nlohmann::json
|
|
|
|
|
|
+/* nJson 异常处理的宏 */
|
|
|
+#define nJsonCatch catch(const nJson::parse_error& e) \
|
|
|
+ { \
|
|
|
+ SPDLOG_WARN("nJson parse failed: {}", e.what());\
|
|
|
+ return false;\
|
|
|
+ }\
|
|
|
+ catch(const nJson::type_error& e) \
|
|
|
+ {\
|
|
|
+ SPDLOG_WARN("nJson type failed: " << e.what());\
|
|
|
+ return false;\
|
|
|
+ }catch (const std::exception& e)\
|
|
|
+ {\
|
|
|
+ SPDLOG_WARN("nJson std failed: " << e.what());\
|
|
|
+ return false;\
|
|
|
+ }catch(...)\
|
|
|
+ {\
|
|
|
+ SPDLOG_WARN("nJson Operated failed: unknown error");\
|
|
|
+ return false;\
|
|
|
+ }
|
|
|
|
|
|
|
|
|
#endif /* COMMONDEFINE_H */
|