Skip to content

Commit 19663c9

Browse files
speedplaneAutomatedTester
authored andcommitted
If the JSON doesn't load, it's likely because the user has another server running on the same port. Improve the error message here so can figure out what's going on more easily.
1 parent 5b5d099 commit 19663c9

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

browsermobproxy/client.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,12 @@ def __init__(self, url, params=None, options=None):
2929
self.port = options['existing_proxy_port_to_use']
3030
else:
3131
resp = requests.post('%s/proxy' % self.host + urlparams)
32-
jcontent = json.loads(resp.content.decode('utf-8'))
32+
content = resp.content.decode('utf-8')
33+
try:
34+
jcontent = json.loads(content)
35+
except Exception as e:
36+
raise Exception("Could not read Browsermob-Proxy json\n"
37+
"Another server running on this port?\n%s..."%content[:512])
3338
self.port = jcontent['port']
3439
url_parts = self.host.split(":")
3540
self.proxy = url_parts[1][2:] + ":" + str(self.port)

0 commit comments

Comments
 (0)