Bug #897054: stack crashes with AttributeError on e.reason if the server returns an error
Swap the URLError and HTTPError exception handlers. HTTPError is a subclass of URLError, so the HTTPError handler wasn't being reached. Change-Id: Iec86d2b345dbd37858af888bbd54a74884025eda
This commit is contained in:
@@ -118,12 +118,12 @@ def do_request(controller, method, params=None):
|
|||||||
req = urllib2.Request(url, data, headers)
|
req = urllib2.Request(url, data, headers)
|
||||||
try:
|
try:
|
||||||
resp = urllib2.urlopen(req)
|
resp = urllib2.urlopen(req)
|
||||||
except urllib2.URLError, e:
|
|
||||||
print 'Failed to connect to %s: %s' % (url, e.reason)
|
|
||||||
sys.exit(1)
|
|
||||||
except urllib2.HTTPError, e:
|
except urllib2.HTTPError, e:
|
||||||
print e.read()
|
print e.read()
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
except urllib2.URLError, e:
|
||||||
|
print 'Failed to connect to %s: %s' % (url, e.reason)
|
||||||
|
sys.exit(1)
|
||||||
return json.loads(resp.read())
|
return json.loads(resp.read())
|
||||||
|
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user