| HTTPError | R Documentation |
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.
HTTPError
An object of class HTTPError (inherits from R6) of length 39.
HTTPErrorFactory:
content_typeType of the error response.
encodeFunction to encode response body.
new()Creates HTTPError object.
HTTPErrorFactory$new(content_type = "text/plain", encode = as.character)
content_typeType of the error response.
encodeFunction to encode response body.
set_content_type()Set content type of response.
HTTPErrorFactory$set_content_type(content_type)
content_typeType of the error response.
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.
set_encode()Set encode for the given content type.
HTTPErrorFactory$set_encode(encode)
encodeFunction to encode response body.
reset()Resets HTTPError to the default RestRserve state.
HTTPErrorFactory$reset()
error()Generate HTTP error response with a given status code and body.
HTTPErrorFactory$error(status_code, body = NULL, ...)
status_codeHTTP status code.
bodyResponse body.
...Additional named arguments which will be passed to Response$new().
headers may be particularly useful.
Response object.
bad_request()Generates corresponding http error.
HTTPErrorFactory$bad_request(...)
...Additional named arguments which will be passed to Response$new().
Response object.
unauthorized()Generates corresponding http error.
HTTPErrorFactory$unauthorized(...)
...Additional named arguments which will be passed to Response$new().
Response object.
forbidden()Generates corresponding http error.
HTTPErrorFactory$forbidden(...)
...Additional named arguments which will be passed to Response$new().
Response object.
not_found()Generates corresponding http error.
HTTPErrorFactory$not_found(...)
...Additional named arguments which will be passed to Response$new().
Response object.
method_not_allowed()Generates corresponding http error.
HTTPErrorFactory$method_not_allowed(...)
...Additional named arguments which will be passed to Response$new().
Response object.
not_acceptable()Generates corresponding http error.
HTTPErrorFactory$not_acceptable(...)
...Additional named arguments which will be passed to Response$new().
Response object.
conflict()Generates corresponding http error.
HTTPErrorFactory$conflict(...)
...Additional named arguments which will be passed to Response$new().
Response object.
gone()Generates corresponding http error.
HTTPErrorFactory$gone(...)
...Additional named arguments which will be passed to Response$new().
Response object.
length_required()Generates corresponding http error.
HTTPErrorFactory$length_required(...)
...Additional named arguments which will be passed to Response$new().
Response object.
precondition_failed()Generates corresponding http error.
HTTPErrorFactory$precondition_failed(...)
...Additional named arguments which will be passed to Response$new().
Response object.
payload_too_large()Generates corresponding http error.
HTTPErrorFactory$payload_too_large(...)
...Additional named arguments which will be passed to Response$new().
Response object.
uri_too_long()Generates corresponding http error.
HTTPErrorFactory$uri_too_long(...)
...Additional named arguments which will be passed to Response$new().
Response object.
unsupported_media_type()Generates corresponding http error.
HTTPErrorFactory$unsupported_media_type(...)
...Additional named arguments which will be passed to Response$new().
Response object.
range_not_satisfiable()Generates corresponding http error.
HTTPErrorFactory$range_not_satisfiable(...)
...Additional named arguments which will be passed to Response$new().
Response object.
unprocessable_entity()Generates corresponding http error.
HTTPErrorFactory$unprocessable_entity(...)
...Additional named arguments which will be passed to Response$new().
Response object.
locked()Generates corresponding http error.
HTTPErrorFactory$locked(...)
...Additional named arguments which will be passed to Response$new().
Response object.
failed_dependency()Generates corresponding http error.
HTTPErrorFactory$failed_dependency(...)
...Additional named arguments which will be passed to Response$new().
Response object.
precondition_required()Generates corresponding http error.
HTTPErrorFactory$precondition_required(...)
...Additional named arguments which will be passed to Response$new().
Response object.
too_many_requests()Generates corresponding http error.
HTTPErrorFactory$too_many_requests(...)
...Additional named arguments which will be passed to Response$new().
Response object.
request_header_fields_too_large()Generates corresponding http error.
HTTPErrorFactory$request_header_fields_too_large(...)
...Additional named arguments which will be passed to Response$new().
Response object.
unavailable_for_legal_reasons()Generates corresponding http error.
HTTPErrorFactory$unavailable_for_legal_reasons(...)
...Additional named arguments which will be passed to Response$new().
Response object.
internal_server_error()Generates corresponding http error.
HTTPErrorFactory$internal_server_error(...)
...Additional named arguments which will be passed to Response$new().
Response object.
not_implemented()Generates corresponding http error.
HTTPErrorFactory$not_implemented(...)
...Additional named arguments which will be passed to Response$new().
Response object.
bad_gateway()Generates corresponding http error.
HTTPErrorFactory$bad_gateway(...)
...Additional named arguments which will be passed to Response$new().
Response object.
service_unavailable()Generates corresponding http error.
HTTPErrorFactory$service_unavailable(...)
...Additional named arguments which will be passed to Response$new().
Response object.
gateway_timeout()Generates corresponding http error.
HTTPErrorFactory$gateway_timeout(...)
...Additional named arguments which will be passed to Response$new().
Response object.
version_not_supported()Generates corresponding http error.
HTTPErrorFactory$version_not_supported(...)
...Additional named arguments which will be passed to Response$new().
Response object.
insufficient_storage()Generates corresponding http error.
HTTPErrorFactory$insufficient_storage(...)
...Additional named arguments which will be passed to Response$new().
Response object.
loop_detected()Generates corresponding http error.
HTTPErrorFactory$loop_detected(...)
...Additional named arguments which will be passed to Response$new().
Response object.
network_authentication_required()Generates corresponding http error.
HTTPErrorFactory$network_authentication_required(...)
...Additional named arguments which will be passed to Response$new().
Response object.
clone()The objects of this class are cloneable with this method.
HTTPErrorFactory$clone(deep = FALSE)
deepWhether to make a deep clone.
raise Application
check_list = function(x) {
if (!is.list(x)) raise(HTTPError$bad_request())
invisible(TRUE)
}
check_list(list())
try(check_list(1), silent = TRUE)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.