circuits.web.exceptions – Exceptions

Exceptions

This module implements a set of standard HTTP Errors as Python Exceptions.

Note: This code is mostly borrowed from werkzeug and adapted for circuits.web

Exceptions

exception circuits.web.exceptions.HTTPException(description=None, traceback=None)

Bases: exceptions.Exception

Baseclass for all HTTP exceptions. This exception can be called by WSGI applications to render a default error page or you can catch the subclasses of it independently and render nicer error messages.

exception circuits.web.exceptions.BadGateway(description=None, traceback=None)

Bases: circuits.web.exceptions.HTTPException

502 Bad Gateway

If you do proxying in your application you should return this status code if you received an invalid response from the upstream server it accessed in attempting to fulfill the request.

exception circuits.web.exceptions.BadRequest(description=None, traceback=None)

Bases: circuits.web.exceptions.HTTPException

400 Bad Request

Raise if the browser sends something to the application the application or server cannot handle.

exception circuits.web.exceptions.Forbidden(description=None, traceback=None)

Bases: circuits.web.exceptions.HTTPException

403 Forbidden

Raise if the user doesn’t have the permission for the requested resource but was authenticated.

exception circuits.web.exceptions.Gone(description=None, traceback=None)

Bases: circuits.web.exceptions.HTTPException

410 Gone

Raise if a resource existed previously and went away without new location.

exception circuits.web.exceptions.InternalServerError(description=None, traceback=None)

Bases: circuits.web.exceptions.HTTPException

500 Internal Server Error

Raise if an internal server error occurred. This is a good fallback if an unknown error occurred in the dispatcher.

exception circuits.web.exceptions.LengthRequired(description=None, traceback=None)

Bases: circuits.web.exceptions.HTTPException

411 Length Required

Raise if the browser submitted data but no Content-Length header which is required for the kind of processing the server does.

exception circuits.web.exceptions.MethodNotAllowed(method, description=None)

Bases: circuits.web.exceptions.HTTPException

405 Method Not Allowed

Raise if the server used a method the resource does not handle. For example POST if the resource is view only. Especially useful for REST.

The first argument for this exception should be a list of allowed methods. Strictly speaking the response would be invalid if you don’t provide valid methods in the header which you can do with that list.

exception circuits.web.exceptions.NotAcceptable(description=None, traceback=None)

Bases: circuits.web.exceptions.HTTPException

406 Not Acceptable

Raise if the server can’t return any content conforming to the Accept headers of the client.

exception circuits.web.exceptions.NotFound(description=None, traceback=None)

Bases: circuits.web.exceptions.HTTPException

404 Not Found

Raise if a resource does not exist and never existed.

exception circuits.web.exceptions.NotImplemented(description=None, traceback=None)

Bases: circuits.web.exceptions.HTTPException

501 Not Implemented

Raise if the application does not support the action requested by the browser.

exception circuits.web.exceptions.PreconditionFailed(description=None, traceback=None)

Bases: circuits.web.exceptions.HTTPException

412 Precondition Failed

Status code used in combination with If-Match, If-None-Match, or If-Unmodified-Since.

exception circuits.web.exceptions.Redirect(urls, status=None)

Bases: circuits.web.exceptions.HTTPException

exception circuits.web.exceptions.RequestEntityTooLarge(description=None, traceback=None)

Bases: circuits.web.exceptions.HTTPException

413 Request Entity Too Large

The status code one should return if the data submitted exceeded a given limit.

exception circuits.web.exceptions.RequestTimeout(description=None, traceback=None)

Bases: circuits.web.exceptions.HTTPException

408 Request Timeout

Raise to signalize a timeout.

exception circuits.web.exceptions.RequestURITooLarge(description=None, traceback=None)

Bases: circuits.web.exceptions.HTTPException

414 Request URI Too Large

Like 413 but for too long URLs.

exception circuits.web.exceptions.ServiceUnavailable(description=None, traceback=None)

Bases: circuits.web.exceptions.HTTPException

503 Service Unavailable

Status code you should return if a service is temporarily unavailable.

exception circuits.web.exceptions.Unauthorized(description=None, traceback=None)

Bases: circuits.web.exceptions.HTTPException

401 Unauthorized

Raise if the user is not authorized. Also used if you want to use HTTP basic auth.

exception circuits.web.exceptions.UnicodeError(description=None, traceback=None)

Bases: circuits.web.exceptions.HTTPException

raised by the request functions if they were unable to decode the incoming data properly.

exception circuits.web.exceptions.UnsupportedMediaType(description=None, traceback=None)

Bases: circuits.web.exceptions.HTTPException

415 Unsupported Media Type

The status code returned if the server is unable to handle the media type the client transmitted.

Events

none

Components

none

Functions

none