|
@@ -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):
|
|
|
"""
|