Skip to content

Commit 7cecd5f

Browse files
committed
catch io exception
1 parent 995e3cb commit 7cecd5f

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

qiniu/rpc.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,14 +44,15 @@ def call_with(self, path, body, content_type=None, content_length=None):
4444
if content_length is not None:
4545
header["Content-Length"] = content_length
4646

47-
resp = self.round_tripper("POST", path, body, header)
4847
try:
48+
resp = self.round_tripper("POST", path, body, header)
4949
ret = resp.read()
5050
ret = json.loads(ret)
51-
except IOError, e:
52-
return None, e
5351
except ValueError:
52+
# ignore empty body when success
5453
pass
54+
except Exception, e:
55+
return None, str(e)+path, 0
5556

5657
if resp.status >= 400:
5758
err_msg = ret if "error" not in ret else ret["error"]

0 commit comments

Comments
 (0)