|
@@ -56,8 +56,12 @@ def _http_call(url, method, token, **message):
|
|
|
resp = urllib.request.urlopen(req, timeout=5)
|
|
|
r = _parse_json(resp.read().decode())
|
|
|
return r
|
|
|
- except urllib.error.URLError as e:
|
|
|
+ except urllib.error.HTTPError as e:
|
|
|
+ # 处理HTTPError,访问代码
|
|
|
raise APIError('-5', 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
|
|
|
|