commit c08a825dd1fa47b8af21a524301e6014fa46819f Author: Arturo Filastò art@fuffa.org 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'})