瀏覽代碼

优化vovi异常捕获

zhangdongming 9 月之前
父節點
當前提交
c6724a9dbf
共有 1 個文件被更改,包括 8 次插入6 次删除
  1. 8 6
      Service/VivoPushService/push_admin/APISenderBase.py

+ 8 - 6
Service/VivoPushService/push_admin/APISenderBase.py

@@ -57,13 +57,15 @@ def _http_call(url, method, token, **message):
         r = _parse_json(resp.read().decode())
         return r
     except urllib.error.HTTPError as e:
-        # 处理HTTPError,访问代码
-        raise APIError('-5', e.reason, 'http error ' + str(e.code))
+        # 处理HTTPError
+        raise APIError('-5', str(e.reason), 'http error ' + str(e.code))
     except urllib.error.URLError as e:
-        # 处理URLError,因为URLError没有code属性
-        raise APIError('-5', e.reason, 'http error: ' + e.reason)
-    except BaseException as e:
-        raise e
+        # 处理URLError
+        raise APIError('-5', str(e.reason), 'http error: ' + str(e.reason))
+    except Exception as e:
+        # 处理其他未知错误
+        raise APIError('-5', str(e), 'Unknown error')
+
 
 def _encode_params(kw):
     """