123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354 |
- #ifndef COMMONDEFINE_H
- #define COMMONDEFINE_H
- #include "nlohmann/json.hpp"
- /*--------------------------------------------------------------------------
- * 公共宏定义
- *--------------------------------------------------------------------------*/
- #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;\
- }
- /* nJson 异常处理的宏,不带返回值 */
- #define nJsonCatchNoReturn catch(const nJson::parse_error& e) \
- { \
- SPDLOG_WARN("nJson parse failed: {}", e.what());\
- return;\
- }\
- catch(const nJson::type_error& e) \
- {\
- SPDLOG_WARN("nJson type failed: {}", e.what());\
- return;\
- }catch (const std::exception& e)\
- {\
- SPDLOG_WARN("nJson std failed: {}", e.what());\
- return;\
- }catch(...)\
- {\
- SPDLOG_WARN("nJson Operated failed: unknown error");\
- return;\
- }
- #endif /* COMMONDEFINE_H */
|