duck.contrib.responses.errorsยถ

Helpers for fast response generation.

Module Contentsยถ

Functionsยถ

get_404_error_response

Returns HttpNotFoundError Response for the request.

get_bad_gateway_error_response

Returns the appropriate Bad Gateway response.

get_bad_request_error_response

Returns HttpBadRequest Response for the request.

get_debug_error_as_html

Returns the exception as html (only if DEBUG=True, else None).

get_method_not_allowed_error_response

Returns HttpMethodNotAllowed Response for the request.

get_server_error_response

Returns HttpServerError Response for the provided exception.

get_timeout_error_response

Returns the request timeout error response.

Dataยถ

debug_error_style

APIยถ

duck.contrib.responses.errors.debug_error_style = <Multiline-String>ยถ
duck.contrib.responses.errors.get_404_error_response(request: duck.http.request.HttpRequest)ยถ

Returns HttpNotFoundError Response for the request.

duck.contrib.responses.errors.get_bad_gateway_error_response(exception: Optional[Exception], request: Optional = None)ยถ

Returns the appropriate Bad Gateway response.

Parameters:
  • exception โ€“ The exception which might have caused this.

  • response. (The exception may be included in)

  • request โ€“ The current http request.

duck.contrib.responses.errors.get_bad_request_error_response(exception: Exception, request: Optional[duck.http.request.HttpRequest] = None)ยถ

Returns HttpBadRequest Response for the request.

Parameters:
  • exception โ€“ The appropriate exception.

  • request โ€“ The http request.

duck.contrib.responses.errors.get_debug_error_as_html(exception: Exception, request: Optional = None)ยถ

Returns the exception as html (only if DEBUG=True, else None).

duck.contrib.responses.errors.get_method_not_allowed_error_response(request: duck.http.request.HttpRequest, route_info: Optional[Dict[str, Any]] = None)ยถ

Returns HttpMethodNotAllowed Response for the request.

Parameters:
  • request โ€“ The http request.

  • route_info โ€“ The route info for the request obtained by RouteRegistry.

duck.contrib.responses.errors.get_server_error_response(exception: Exception, request: Optional = None)ยถ

Returns HttpServerError Response for the provided exception.

duck.contrib.responses.errors.get_timeout_error_response(timeout: Optional[Union[int, float]]) โ†’ duck.http.response.HttpRequestTimeoutResponseยถ

Returns the request timeout error response.

Parameters:

timeout โ€“ The timeout in seconds.