Explorar el Código

V0.11.5
1、添加了WebAPI的异常处理的宏

Apple hace 3 días
padre
commit
83a6e9b7c6
Se han modificado 1 ficheros con 19 adiciones y 0 borrados
  1. 19 0
      common/communication/WebAPIBase.h

+ 19 - 0
common/communication/WebAPIBase.h

@@ -7,6 +7,25 @@
 
 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
 {
 public: