Skip to contents

These error classes are for each HTTP error, and inherit from the Error class in this package.

Details

In addition to what's available in Error, these classes have a single variable mssg that is the very verbose complete message describing the HTTP condition in detail. You can include that message in your condition by using do_verbose (see below)

Methods

In addition to the methods documented in Error, these methods also have:

  • do_verbose(response, template) Execute condition, whether it be message, warning, or error.

    • response: is any response from crul, curl, or httr Execute condition, whether it be message, warning, error, or your own custom function. This method uses message_template_verbose, and uses it's default value.

    • template: a template to use for the verbose message, see Error for details

See also

Examples

if (requireNamespace("crul")) {

 library("crul")
 res <- HttpClient$new("https://httpbin.org/status/414")$get()
 x <- HTTPRequestURITooLong$new()
 x
 if (FALSE) {
 x$do(res)
 x$do_verbose(res)
 }

 # behavior
 x <- HTTPRequestURITooLong$new(behavior = "warning")
 if (FALSE) {
 x$do(res)
 x$do_verbose(res)
 }

 x <- HTTPRequestURITooLong$new(behavior = "message")
 if (FALSE) {
 x$do(res)
 x$do_verbose(res)
 }

 # with message template
 (x <- HTTPRequestURITooLong$new(
   message_template = "{{reason}} ............ {{status}}",
   message_template_verbose = "{{reason}} .>.>.>.>.>.> {{status}}\n {{message}}"
 ))
 if (FALSE) {
 x$do(res)
 x$do_verbose(res)
 }
}