Browse Source

V0.11.6
1、将nJson的宏定义移到了公共头文件上

Apple 2 days ago
parent
commit
a8168bb492
2 changed files with 19 additions and 18 deletions
  1. 19 0
      common/commonDefine.h
  2. 0 18
      common/communication/WebAPIBase.h

+ 19 - 0
common/commonDefine.h

@@ -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 */

+ 0 - 18
common/communication/WebAPIBase.h

@@ -7,24 +7,6 @@
 
 class lhhttpapi;
 
-#define nJsonCatch catch(const nJson::parse_error& e)       \
-    {   \
-        mCritical << "WebAPI parse failed: " << e.what();\
-        return false;\
-    }\
-    catch(const nJson::type_error& e)                       \
-    {\
-        mCritical << "WebAPI type failed: " << e.what();\
-        return false;\
-    }catch (const std::exception& e)\
-    {\
-        mCritical << "WebAPI std failed: " << e.what();\
-        return false;\
-    }catch(...)\
-    {\
-        mCritical << "WebAPI Operated failed: unknown error";\
-        return false;\
-    }
 
 class WebAPIBase
 {