Package cherrypy :: Module _cperror :: Class HTTPError
[hide private]
[frames] | no frames]

Class HTTPError

source code

              object --+            
                       |            
exceptions.BaseException --+        
                           |        
        exceptions.Exception --+    
                               |    
               CherryPyException --+
                                   |
                                  HTTPError
Known Subclasses:

Exception used to return an HTTP error code (4xx-5xx) to the client.

This exception can be used to automatically send a response using a http status code, with an appropriate error page. It takes an optional ``status`` argument (which must be between 400 and 599); it defaults to 500 ("Internal Server Error"). It also takes an optional ``message`` argument, which will be returned in the response body. See `RFC 2616 <http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.4>`_ for a complete list of available error codes and when to use them.

Examples:

   raise cherrypy.HTTPError(403)
   raise cherrypy.HTTPError("403 Forbidden", "You are not allowed to access this resource.")
Instance Methods [hide private]
 
__init__(self, status=500, message=None)
x.__init__(...) initializes x; see help(type(x)) for signature
source code
 
set_response(self)
Modify cherrypy.response status, headers, and body to represent self.
source code
 
get_error_page(self, *args, **kwargs) source code
 
__call__(self)
Use this exception as a request.handler (raise self).
source code

Inherited from exceptions.Exception: __new__

Inherited from exceptions.BaseException: __delattr__, __getattribute__, __getitem__, __getslice__, __reduce__, __repr__, __setattr__, __setstate__, __str__, __unicode__

Inherited from object: __format__, __hash__, __reduce_ex__, __sizeof__, __subclasshook__

Class Variables [hide private]
  status = None
The HTTP status code.
  code = None
The integer HTTP status code.
  reason = None
The HTTP Reason-Phrase string.
Properties [hide private]

Inherited from exceptions.BaseException: args, message

Inherited from object: __class__

Method Details [hide private]

__init__(self, status=500, message=None)
(Constructor)

source code 

x.__init__(...) initializes x; see help(type(x)) for signature

Overrides: object.__init__
(inherited documentation)

set_response(self)

source code 

Modify cherrypy.response status, headers, and body to represent self.

CherryPy uses this internally, but you can also use it to create an HTTPError object and set its output without *raising* the exception.


Class Variable Details [hide private]

status

The HTTP status code. May be of type int or str (with a Reason-Phrase).

Value:
None