[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[tor-commits] [ooni-probe/master] Handle exceptions in backend queries better.



commit 5817a3d920b1ba24ba295ac331df8871c33a095c
Author: Arturo Filastò <art@xxxxxxxxx>
Date:   Thu Sep 12 15:00:47 2013 +0200

    Handle exceptions in backend queries better.
---
 ooni/oonibclient.py |    8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/ooni/oonibclient.py b/ooni/oonibclient.py
index 455aea8..6be7c44 100644
--- a/ooni/oonibclient.py
+++ b/ooni/oonibclient.py
@@ -87,7 +87,10 @@ class OONIBClient(object):
         
         def genReceiver(finished, content_length):
             def process_response(s):
-                response = json.loads(s)
+                try:
+                    response = json.loads(s)
+                except ValueError:
+                    raise e.get_error(None)
                 if 'error' in response:
                     print "Got this backend error message %s" % response
                     log.err("Got this backend error message %s" % response)
@@ -216,7 +219,8 @@ class OONIBClient(object):
 
             test_helper = yield self.queryBackend('POST', '/bouncer', 
                             query={'test-helpers': test_helper_names})
-        except Exception:
+        except Exception, e:
+            log.exception(e)
             raise e.CouldNotFindTestHelper
 
         if not test_helper:



_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits