cli: if response code from wapi server is not 200 then stop instead of proceeding

Also, include the data that failed to json parse in an exception raised by the json parser.
This commit is contained in:
Zooko O'Whielacronx 2008-12-20 07:49:18 -07:00
parent ec86563326
commit c79230c854

View File

@ -30,13 +30,22 @@ def list(options):
print >>stderr, "Error during GET: %s %s %s" % (resp.status,
resp.reason,
resp.read())
if resp.status == 0:
return 3
else:
return resp.status
data = resp.read()
if options['json']:
print >>stdout, data
return
parsed = simplejson.loads(data)
try:
parsed = simplejson.loads(data)
except Exception, le:
le.args = tuple(le.args + (data,))
raise
nodetype, d = parsed
children = {}
if nodetype == "dirnode":