Skip to content

Commit 7fccdb9

Browse files
committed
HTTPError handling
1 parent dc0b462 commit 7fccdb9

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

scan/client/scanclient.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,13 @@ def perform_request(url, method='GET', data=None, timeout=None):
113113
try:
114114
response.raise_for_status()
115115
except requests.HTTPError as e:
116-
raise Exception("Scan server at %s returned error code %d" % (url, e.response.code))
116+
msg = "Scan server at %s returned error" % url
117+
if hasattr(e, 'response'):
118+
if hasattr(e.response, 'status_code'):
119+
msg += " code %d" % e.response.status_code
120+
if hasattr(e.response, '_content'):
121+
msg += "\n" + e.response._content
122+
raise Exception(msg)
117123

118124
return response.text
119125

scan/version.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
from __future__ import print_function
22

3-
__version__ = '1.8.0'
3+
__version__ = '1.8.1'
44

55
version_history = """
6+
1.8.1 - Fix error in requests.HTTPError handling
67
1.8.0 - Set command with 'readback_value'
78
1.7.0 - CommandSequence class inherits from list
89
1.6.0 - Add support for Python3, CPython uses requests library

0 commit comments

Comments
 (0)