Ticket #733 (defect)
Opened 10 months ago
Last modified 8 months ago
404 instead of 500 on wrong number of arguments
Status: assigned
| Reported by: | fumanchu | Assigned to: | fumanchu (accepted) |
|---|---|---|---|
| Priority: | normal | Milestone: | 3.2 |
| Component: | CherryPy code | Keywords: | |
| Cc: |
Currently, calling a handler with the wrong number of arguments results in a 500 error. A 404 might be better. The following patch (against trunk) tries to do this:
Index: _cpdispatch.py
===================================================================
--- _cpdispatch.py (revision 1716)
+++ _cpdispatch.py (working copy)
@@ -21,7 +21,14 @@
self.kwargs = kwargs
def __call__(self):
- return self.callable(*self.args, **self.kwargs)
+ try:
+ return self.callable(*self.args, **self.kwargs)
+ except TypeError, x:
+ import re
+ if re.match(r'%s\(\) takes .+ arguments? \(.+ given\)' %
+ re.escape(self.callable.__name__), x.args[0]):
+ raise cherrypy.HTTPError(404)
+ raise
class LateParamPageHandler(PageHandler):
Change History
09/21/07 11:23:56: Modified by fumanchu
- status changed from new to assigned.
10/26/07 00:45:34: Modified by fumanchu
- milestone changed from 3.1 to 3.2.


Here's a better one:
Not sure what to do about the mixing of querystring and entity params...is half a solution better than none? or worse?