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.
Methods
Method new()
Creates HTTPError object.
Arguments
content_type
Type of the error response.
encode
Function to encode response body.
Method set_content_type()
Set content type of response.
Usage
HTTPErrorFactory$set_content_type(content_type)
Arguments
content_type
Type of the error response.
Details
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.
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.
Method bad_request()
Generates corresponding http error.
Usage
HTTPErrorFactory$bad_request(...)
Arguments
...
Additional named arguments which will be passed to Response$new()
.
Method unauthorized()
Generates corresponding http error.
Usage
HTTPErrorFactory$unauthorized(...)
Arguments
...
Additional named arguments which will be passed to Response$new()
.
Method forbidden()
Generates corresponding http error.
Usage
HTTPErrorFactory$forbidden(...)
Arguments
...
Additional named arguments which will be passed to Response$new()
.
Method not_found()
Generates corresponding http error.
Usage
HTTPErrorFactory$not_found(...)
Arguments
...
Additional named arguments which will be passed to Response$new()
.
Method method_not_allowed()
Generates corresponding http error.
Usage
HTTPErrorFactory$method_not_allowed(...)
Arguments
...
Additional named arguments which will be passed to Response$new()
.
Method not_acceptable()
Generates corresponding http error.
Usage
HTTPErrorFactory$not_acceptable(...)
Arguments
...
Additional named arguments which will be passed to Response$new()
.
Method conflict()
Generates corresponding http error.
Usage
HTTPErrorFactory$conflict(...)
Arguments
...
Additional named arguments which will be passed to Response$new()
.
Method gone()
Generates corresponding http error.
Usage
HTTPErrorFactory$gone(...)
Arguments
...
Additional named arguments which will be passed to Response$new()
.
Method length_required()
Generates corresponding http error.
Usage
HTTPErrorFactory$length_required(...)
Arguments
...
Additional named arguments which will be passed to Response$new()
.
Method precondition_failed()
Generates corresponding http error.
Usage
HTTPErrorFactory$precondition_failed(...)
Arguments
...
Additional named arguments which will be passed to Response$new()
.
Method payload_too_large()
Generates corresponding http error.
Usage
HTTPErrorFactory$payload_too_large(...)
Arguments
...
Additional named arguments which will be passed to Response$new()
.
Method uri_too_long()
Generates corresponding http error.
Usage
HTTPErrorFactory$uri_too_long(...)
Arguments
...
Additional named arguments which will be passed to Response$new()
.
Generates corresponding http error.
Usage
HTTPErrorFactory$unsupported_media_type(...)
Arguments
...
Additional named arguments which will be passed to Response$new()
.
Method range_not_satisfiable()
Generates corresponding http error.
Usage
HTTPErrorFactory$range_not_satisfiable(...)
Arguments
...
Additional named arguments which will be passed to Response$new()
.
Method unprocessable_entity()
Generates corresponding http error.
Usage
HTTPErrorFactory$unprocessable_entity(...)
Arguments
...
Additional named arguments which will be passed to Response$new()
.
Method locked()
Generates corresponding http error.
Usage
HTTPErrorFactory$locked(...)
Arguments
...
Additional named arguments which will be passed to Response$new()
.
Method failed_dependency()
Generates corresponding http error.
Usage
HTTPErrorFactory$failed_dependency(...)
Arguments
...
Additional named arguments which will be passed to Response$new()
.
Method precondition_required()
Generates corresponding http error.
Usage
HTTPErrorFactory$precondition_required(...)
Arguments
...
Additional named arguments which will be passed to Response$new()
.
Method too_many_requests()
Generates corresponding http error.
Usage
HTTPErrorFactory$too_many_requests(...)
Arguments
...
Additional named arguments which will be passed to Response$new()
.
Generates corresponding http error.
Usage
HTTPErrorFactory$request_header_fields_too_large(...)
Arguments
...
Additional named arguments which will be passed to Response$new()
.
Method unavailable_for_legal_reasons()
Generates corresponding http error.
Usage
HTTPErrorFactory$unavailable_for_legal_reasons(...)
Arguments
...
Additional named arguments which will be passed to Response$new()
.
Method internal_server_error()
Generates corresponding http error.
Usage
HTTPErrorFactory$internal_server_error(...)
Arguments
...
Additional named arguments which will be passed to Response$new()
.
Method not_implemented()
Generates corresponding http error.
Usage
HTTPErrorFactory$not_implemented(...)
Arguments
...
Additional named arguments which will be passed to Response$new()
.
Method bad_gateway()
Generates corresponding http error.
Usage
HTTPErrorFactory$bad_gateway(...)
Arguments
...
Additional named arguments which will be passed to Response$new()
.
Method service_unavailable()
Generates corresponding http error.
Usage
HTTPErrorFactory$service_unavailable(...)
Arguments
...
Additional named arguments which will be passed to Response$new()
.
Method gateway_timeout()
Generates corresponding http error.
Usage
HTTPErrorFactory$gateway_timeout(...)
Arguments
...
Additional named arguments which will be passed to Response$new()
.
Method version_not_supported()
Generates corresponding http error.
Usage
HTTPErrorFactory$version_not_supported(...)
Arguments
...
Additional named arguments which will be passed to Response$new()
.
Method insufficient_storage()
Generates corresponding http error.
Usage
HTTPErrorFactory$insufficient_storage(...)
Arguments
...
Additional named arguments which will be passed to Response$new()
.
Method loop_detected()
Generates corresponding http error.
Usage
HTTPErrorFactory$loop_detected(...)
Arguments
...
Additional named arguments which will be passed to Response$new()
.
Method network_authentication_required()
Generates corresponding http error.
Usage
HTTPErrorFactory$network_authentication_required(...)
Arguments
...
Additional named arguments which will be passed to Response$new()
.
Method clone()
The objects of this class are cloneable with this method.
Usage
HTTPErrorFactory$clone(deep = FALSE)
Arguments
deep
Whether to make a deep clone.