diff roundup/cgi/actions.py @ 5165:a86860224d80

issue2550755: exceptions.NotFound(msg) msg is not reported to user in cgi. When an invalid column is specified return error code 400 rather than 404. Make error code 400 also return an error message to the user. Reported by: Bernhard Reiter. After I implemented this it occurred to me that this may be better implemented using a new exception BadRequest and handle that instead. I really don't have a good feel for which is better from an architectural view although I have a feeling the exception path would be better.
author John Rouillard <rouilj@ieee.org>
date Mon, 15 Aug 2016 20:53:37 -0400
parents 114d9628fd77
children 4f99aad7e8e8
line wrap: on
line diff
--- a/roundup/cgi/actions.py	Sat Jul 23 17:21:14 2016 -0400
+++ b/roundup/cgi/actions.py	Mon Aug 15 20:53:37 2016 -0400
@@ -1256,11 +1256,11 @@
         props = klass.getprops()
         for cname in columns:
             if cname not in props:
-                # TODO raise exceptions.NotFound(.....) does not give message
-                # so using SeriousError instead
-                self.client.response_code = 404
-                raise exceptions.SeriousError(
-                    self._('Column "%(column)s" not found on %(class)s')
+                # use error code 400: Bad Request. Do not use
+                # error code 404: Not Found.
+                self.client.response_code = 400
+                raise exceptions.NotFound(
+                    self._('Column "%(column)s" not found in %(class)s')
                     % {'column': cgi.escape(cname), 'class': request.classname})
 
         # full-text search

Roundup Issue Tracker: http://roundup-tracker.org/