commonDefine.h 893 B

12345678910111213141516171819202122232425262728293031323334
  1. #ifndef COMMONDEFINE_H
  2. #define COMMONDEFINE_H
  3. #include "nlohmann/json.hpp"
  4. /*--------------------------------------------------------------------------
  5. * 公共宏定义
  6. *--------------------------------------------------------------------------*/
  7. #define nJson nlohmann::json
  8. /* nJson 异常处理的宏 */
  9. #define nJsonCatch catch(const nJson::parse_error& e) \
  10. { \
  11. SPDLOG_WARN("nJson parse failed: {}", e.what());\
  12. return false;\
  13. }\
  14. catch(const nJson::type_error& e) \
  15. {\
  16. SPDLOG_WARN("nJson type failed: " << e.what());\
  17. return false;\
  18. }catch (const std::exception& e)\
  19. {\
  20. SPDLOG_WARN("nJson std failed: " << e.what());\
  21. return false;\
  22. }catch(...)\
  23. {\
  24. SPDLOG_WARN("nJson Operated failed: unknown error");\
  25. return false;\
  26. }
  27. #endif /* COMMONDEFINE_H */