Issue #898 resolved

HTTPError should accept status code in same format as get_error_page

guest
created an issue

The HTTPError exception class is useful for raising exceptions within cherrypy applications.

However, it is currently limited to integer status codes (as of 3.1.1), instead of the richer "CODE Reason-Phrase" format that get_error_page allows.

Because of this limitation, it is currently impossible (as far as I know) to customise the status line response cherrypy provides to clients when an HTTPError occurs (such as a 404).

Even if it is possible to customise it (by overriding an error handler or some such) it seems logical that HTTPError.init could do the same thing get_error_page does to obtain the code from status:

code, reason, message = _http.valid_status(status)

...that would make calls such as this:

raise cherrypy.HTTPError("404 My Reason Phrase", "User Message")

...possible.

Comments (2)

  1. Log in to comment