[tor-commits] [oonib/master] Handle writing exceptions that don't have log_exception attribute

art at torproject.org art at torproject.org
Wed Apr 23 14:31:52 UTC 2014


commit 0148e9951a7fc7505becd2bfb47e3fcae6c05533
Author: Arturo Filastò <art at fuffa.org>
Date:   Mon Apr 21 19:37:10 2014 +0200

    Handle writing exceptions that don't have log_exception attribute
---
 oonib/handlers.py |    4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/oonib/handlers.py b/oonib/handlers.py
index 2231a2a..20c831b 100644
--- a/oonib/handlers.py
+++ b/oonib/handlers.py
@@ -6,8 +6,10 @@ from cyclone import web
 class OONIBHandler(web.RequestHandler):
     def write_error(self, status_code, exception=None, **kw):
         self.set_status(status_code)
-        if exception:
+        if hasattr(exception, 'log_message'):
             self.write({'error': exception.log_message})
+        else:
+            self.write({'error': 'error'})
 
     def write(self, chunk):
         """





More information about the tor-commits mailing list