adhocracy_core.rest.exceptions module

HTTP Exception (500, 310, 404,..) processing.

exception JSONHTTPClientError(error_entries: [<class 'adhocracy_core.interfaces.ErrorEntry'>], request: pyramid.request.Request=None, code: int=400, title: str='Bad Request')[source]

Bases: pyramid.httpexceptions.HTTPClientError

HTTPException with json body to describe the exception.

Parameters:
  • errors – error entries to generate the error description.
  • request – Request causing the error to log debug information.
  • code – http status code
  • title – http status title

The body contains a dictionary with the following data structure:

  • status: ‘error’
  • errors: [error_entry]
handle_error_500_exception(error, request)[source]

Return 500 JSON error.

handle_error_x0x_exception(error, request)[source]

Return HTTPError.

handle_error_40x_exception(error, request)[source]

Return JSON error for generic HTTPClientErrors.

If error is JSONHTTPClientError it is return without modifications.

handle_error_400_colander_invalid(invalid, request)[source]

Return JSON error for colander.Invalid errors.

handle_error_400_bad_request(error, request)[source]

Return 400 JSON error with filtered error messages.

get_json_body(request: pyramid.request.Request) → object[source]

Return json body of request, defaults to empty dict.

handle_error_400_auto_update_no_fork_allowed(error, request)[source]

Return 400 JSON error for the internal “No Fork allowed” error.

Assuming there was a post request with wrong values for ‘root_versions’.

handle_error_400_url_decode_error(error, request)[source]

Handle error thrown by Pyramid if the request path is not valid UTF-8.

E.g. “/fooba%E9r/”.

handle_error_410_exception(error, request)[source]

Add json body with explanation to 410 errors.

includeme(config)[source]

Include pyramid configuration.