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

[tor-commits] [oonib/master] Raise errors when report is not found



commit c08a825dd1fa47b8af21a524301e6014fa46819f
Author: Arturo Filastò <art@xxxxxxxxx>
Date:   Fri Nov 7 12:11:05 2014 +0100

    Raise errors when report is not found
---
 oonib/report/handlers.py | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/oonib/report/handlers.py b/oonib/report/handlers.py
index 9aa5df9..7f7da20 100644
--- a/oonib/report/handlers.py
+++ b/oonib/report/handlers.py
@@ -202,14 +202,16 @@ class UpdateReportMixin(object):
         log.debug("Got this request %s" % parsed_request)
         report_filename = os.path.join(self.report_dir,
                                        report_id)
-
-        self.reports[report_id].refresh()
+        try:
+            self.reports[report_id].refresh()
+        except KeyError:
+            raise e.OONIBError(404, "Report not found")
 
         try:
             with open(report_filename, 'a+') as fd:
                 fd.write(parsed_request['content'])
         except IOError:
-            e.OONIBError(404, "Report not found")
+            raise e.OONIBError(404, "Report not found")
         self.write({'status': 'success'})
 
 



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