]> git.rkrishnan.org Git - tahoe-lafs/tahoe-lafs.git/commitdiff
cli: if response code from wapi server is not 200 then stop instead of proceeding
authorZooko O'Whielacronx <zooko@zooko.com>
Sat, 20 Dec 2008 14:49:18 +0000 (07:49 -0700)
committerZooko O'Whielacronx <zooko@zooko.com>
Sat, 20 Dec 2008 14:49:18 +0000 (07:49 -0700)
Also, include the data that failed to json parse in an exception raised by the json parser.

src/allmydata/scripts/tahoe_ls.py

index d0d63799be51696a188581e7453bcd637aadb12f..88e09a479c0247bbf832dc78808c389b41c33d70 100644 (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":