Global Object which holds functions to raise common http error responses. Most of the time this class is used jointly with raise .
For example calling raise(HTTPError$bad_request(body = "request is invalid")) from any place in the user code will interrupt request processing and return response with status code = 404 and body = "request is invalid".
Class to generate HTTP error responses.
data
Format
An object of class HTTPError (inherits from R6) of length 39.
Modifying HTTPError will have global impact on RestRserve functionality.
By default HTTPError is used by Application in order to produce http errors (404, 500, etc). Hence changing HTTPError with HTTPErrorFactory$set_content_type() will impact not only user code, but also the errors format produced by RestRserve. Same holds for HTTPErrorFactory$set_encode() method below.
Method set_encode()
Set encode for the given content type.
Usage
HTTPErrorFactory$set_encode(encode)
Arguments
encode: Function to encode response body.
Method reset()
Resets HTTPError to the default RestRserve state.
Usage
HTTPErrorFactory$reset()
Method error()
Generate HTTP error response with a given status code and body.
Usage
HTTPErrorFactory$error(status_code, body = NULL, ...)
Arguments
status_code: HTTP status code.
body: Response body.
...: Additional named arguments which will be passed to Response$new(). headers may be particularly useful.
Returns
Response object.
Method bad_request()
Generates corresponding http error.
Usage
HTTPErrorFactory$bad_request(...)
Arguments
...: Additional named arguments which will be passed to Response$new().
Returns
Response object.
Method unauthorized()
Generates corresponding http error.
Usage
HTTPErrorFactory$unauthorized(...)
Arguments
...: Additional named arguments which will be passed to Response$new().
Returns
Response object.
Method forbidden()
Generates corresponding http error.
Usage
HTTPErrorFactory$forbidden(...)
Arguments
...: Additional named arguments which will be passed to Response$new().
Returns
Response object.
Method not_found()
Generates corresponding http error.
Usage
HTTPErrorFactory$not_found(...)
Arguments
...: Additional named arguments which will be passed to Response$new().
Returns
Response object.
Method method_not_allowed()
Generates corresponding http error.
Usage
HTTPErrorFactory$method_not_allowed(...)
Arguments
...: Additional named arguments which will be passed to Response$new().
Returns
Response object.
Method not_acceptable()
Generates corresponding http error.
Usage
HTTPErrorFactory$not_acceptable(...)
Arguments
...: Additional named arguments which will be passed to Response$new().
Returns
Response object.
Method conflict()
Generates corresponding http error.
Usage
HTTPErrorFactory$conflict(...)
Arguments
...: Additional named arguments which will be passed to Response$new().
Returns
Response object.
Method gone()
Generates corresponding http error.
Usage
HTTPErrorFactory$gone(...)
Arguments
...: Additional named arguments which will be passed to Response$new().
Returns
Response object.
Method length_required()
Generates corresponding http error.
Usage
HTTPErrorFactory$length_required(...)
Arguments
...: Additional named arguments which will be passed to Response$new().
Returns
Response object.
Method precondition_failed()
Generates corresponding http error.
Usage
HTTPErrorFactory$precondition_failed(...)
Arguments
...: Additional named arguments which will be passed to Response$new().
Returns
Response object.
Method payload_too_large()
Generates corresponding http error.
Usage
HTTPErrorFactory$payload_too_large(...)
Arguments
...: Additional named arguments which will be passed to Response$new().
Returns
Response object.
Method uri_too_long()
Generates corresponding http error.
Usage
HTTPErrorFactory$uri_too_long(...)
Arguments
...: Additional named arguments which will be passed to Response$new().
Returns
Response object.
Method unsupported_media_type()
Generates corresponding http error.
Usage
HTTPErrorFactory$unsupported_media_type(...)
Arguments
...: Additional named arguments which will be passed to Response$new().
Returns
Response object.
Method range_not_satisfiable()
Generates corresponding http error.
Usage
HTTPErrorFactory$range_not_satisfiable(...)
Arguments
...: Additional named arguments which will be passed to Response$new().
Returns
Response object.
Method unprocessable_entity()
Generates corresponding http error.
Usage
HTTPErrorFactory$unprocessable_entity(...)
Arguments
...: Additional named arguments which will be passed to Response$new().
Returns
Response object.
Method locked()
Generates corresponding http error.
Usage
HTTPErrorFactory$locked(...)
Arguments
...: Additional named arguments which will be passed to Response$new().
Returns
Response object.
Method failed_dependency()
Generates corresponding http error.
Usage
HTTPErrorFactory$failed_dependency(...)
Arguments
...: Additional named arguments which will be passed to Response$new().
Returns
Response object.
Method precondition_required()
Generates corresponding http error.
Usage
HTTPErrorFactory$precondition_required(...)
Arguments
...: Additional named arguments which will be passed to Response$new().
Returns
Response object.
Method too_many_requests()
Generates corresponding http error.
Usage
HTTPErrorFactory$too_many_requests(...)
Arguments
...: Additional named arguments which will be passed to Response$new().