Skip to content

Commit 51ac716

Browse files
committed
Improved exception handling
Error messsage returned frin server is added to HTTP Error.
1 parent 78054e7 commit 51ac716

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

orionsdk/swisclient.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,5 +48,13 @@ def _req(self, method, frag, data=None):
4848
verify=self.verify,
4949
auth=self.credentials,
5050
headers={'Content-Type': 'application/json'})
51+
52+
# try to extract reason from response when request returns error
53+
if 400 <= resp.status_code < 600:
54+
try:
55+
resp.reason = json.loads(resp.text)['Message'];
56+
except:
57+
pass;
58+
5159
resp.raise_for_status()
5260
return resp

0 commit comments

Comments
 (0)