The exc module is accessible via the webob module.
This module processes Python exceptions that relate to HTTP exceptions by defining a set of exceptions, all subclasses of HTTPException. Each exception, in addition to being a Python exception that can be raised and caught, is also a WSGI application and webob.Response object.
This module defines exceptions according to RFC 2068 [1] : codes with 100-300 are not really errors; 400's are client errors, and 500's are server errors. According to the WSGI specification [2] , the application can call start_response more then once only under two conditions: (a) the response has not yet been sent, or (b) if the second and subsequent invocations of start_response have a valid exc_info argument obtained from sys.exc_info(). The WSGI specification then requires the server or gateway to handle the case where content has been sent and then an exception was encountered.
References:
| [1] | http://www.python.org/peps/pep-0333.html#error-handling |
| [2] | http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.5 |
{200: <class 'webob.exc.HTTPOk'>,
201: <class 'webob.exc.HTTPCreated'>,
202: <class 'webob.exc.HTTPAccepted'>,
203: <class 'webob.exc.HTTPNonAuthoritativeInformation'>,
204: <class 'webob.exc.HTTPNoContent'>,
205: <class 'webob.exc.HTTPResetContent'>,
206: <class 'webob.exc.HTTPPartialContent'>,
300: <class 'webob.exc.HTTPMultipleChoices'>,
301: <class 'webob.exc.HTTPMovedPermanently'>,
302: <class 'webob.exc.HTTPFound'>,
303: <class 'webob.exc.HTTPSeeOther'>,
304: <class 'webob.exc.HTTPNotModified'>,
305: <class 'webob.exc.HTTPUseProxy'>,
307: <class 'webob.exc.HTTPTemporaryRedirect'>,
400: <class 'webob.exc.HTTPClientError'>,
401: <class 'webob.exc.HTTPUnauthorized'>,
402: <class 'webob.exc.HTTPPaymentRequired'>,
403: <class 'webob.exc.HTTPForbidden'>,
404: <class 'webob.exc.HTTPNotFound'>,
405: <class 'webob.exc.HTTPMethodNotAllowed'>,
406: <class 'webob.exc.HTTPNotAcceptable'>,
407: <class 'webob.exc.HTTPProxyAuthenticationRequired'>,
408: <class 'webob.exc.HTTPRequestTimeout'>,
409: <class 'webob.exc.HTTPConflict'>,
410: <class 'webob.exc.HTTPGone'>,
411: <class 'webob.exc.HTTPLengthRequired'>,
412: <class 'webob.exc.HTTPPreconditionFailed'>,
413: <class 'webob.exc.HTTPRequestEntityTooLarge'>,
414: <class 'webob.exc.HTTPRequestURITooLong'>,
415: <class 'webob.exc.HTTPUnsupportedMediaType'>,
416: <class 'webob.exc.HTTPRequestRangeNotSatisfiable'>,
417: <class 'webob.exc.HTTPExpectationFailed'>,
422: <class 'webob.exc.HTTPUnprocessableEntity'>,
423: <class 'webob.exc.HTTPLocked'>,
424: <class 'webob.exc.HTTPFailedDependency'>,
500: <class 'webob.exc.HTTPInternalServerError'>,
501: <class 'webob.exc.HTTPNotImplemented'>,
502: <class 'webob.exc.HTTPBadGateway'>,
503: <class 'webob.exc.HTTPServiceUnavailable'>,
504: <class 'webob.exc.HTTPGatewayTimeout'>,
505: <class 'webob.exc.HTTPVersionNotSupported'>,
507: <class 'webob.exc.HTTPInsufficientStorage'>}
Exception used on pre-Python-2.5, where new-style classes cannot be used as an exception.
This class contains 4 members.
This class contains 50 members.
base class for status codes in the 400's and 500's
This is an exception which indicates that an error has occurred, and that any work in progress should not be committed. These are typically results in the 400's and 500's.
This class contains 54 members.
base class for 300's status code (redirections)
This is an abstract base class for 3xx redirection. It indicates that further action needs to be taken by the user agent in order to fulfill the request. It does not necessarly signal an error condition.
This class contains 54 members.
Base class for the 200's status code (successful responses)
This class contains 50 members.
This class contains 50 members.
This class contains 50 members.
This class contains 50 members.
This class contains 50 members.
This class contains 50 members.
This class contains 50 members.
This class contains 54 members.
This class contains 54 members.
This class contains 54 members.
This class contains 54 members.
This class contains 55 members.
This class contains 54 members.
This class contains 54 members.
base class for the 400's, where the client is in error
This is an error condition in which the client is presumed to be in-error. This is an expected problem, and thus is not considered a bug. A server-side traceback is not warranted. Unless specialized, this is a '400 Bad Request'
This class contains 54 members.
This class contains 54 members.
This class contains 54 members.
This class contains 54 members.
This class contains 54 members.
This class contains 54 members.
This class contains 54 members.
This class contains 54 members.
This class contains 54 members.
This class contains 54 members.
This class contains 54 members.
This class contains 54 members.
This class contains 54 members.
This class contains 54 members.
This class contains 54 members.
This class contains 54 members.
This class contains 55 members.
This class contains 54 members.
This class contains 54 members.
This class contains 54 members.
This class contains 54 members.
This class contains 54 members.
base class for the 500's, where the server is in-error
This is an error condition in which the server is presumed to be in-error. This is usually unexpected, and thus requires a traceback; ideally, opening a support ticket for the customer. Unless specialized, this is a '500 Internal Server Error'
This class contains 54 members.
This class contains 54 members.
This class contains 54 members.
This class contains 54 members.
This class contains 54 members.
This class contains 54 members.
This class contains 54 members.
This class contains 54 members.
Middleware that catches exceptions in the sub-application. This does not catch exceptions in the app_iter; only during the initial calling of the application.
This should be put very close to applications that might raise these exceptions. This should not be applied globally; letting expected exceptions raise through the WSGI stack is dangerous.
This class contains 2 members.
See the source for more information.