HTTP error helpers. Methods included for general purpose HTTP error handling, as well as individual methods for every HTTP status code, both via status code numbers as well as their descriptive names. Supports ability to adjust behavior to stop, message or warning. Includes ability to use custom whisker template to have any configuration of status code, short description, and verbose message. Currently supports integration with 'crul', 'curl', and 'httr'.
fauxpas does http errors
library("crul")cli <- HttpClient$new("")res <- cli$get()http(res)#> Error: Request-URI Too Long (HTTP 414).http414(res)#> Error: Request-URI Too Long (HTTP 414).
x <- HTTPRequestURITooLong$new()x$do_verbose(res)#> Error: Request-URI Too Long (HTTP 414).#> - The server is refusing to service the request because the Request-URI is#> longer than the server is willing to interpret. This rare condition is only likely#> to occur when a client has improperly converted a POST request to a GET request#> with long query information, when the client has descended into a URI black hole#> of redirection (e.g., a redirected URI prefix that points to a suffix of itself),#> or when the server is under attack by a client attempting to exploit security#> holes present in some servers using fixed-length buffers for reading or#> manipulating the Request-URI.
library("curl")h <- curl::new_handle()curl::handle_setopt(h)resp <- curl::curl_fetch_memory("", h)http(resp)#> Error: Not Found (HTTP 404).http404(resp)#> Error: Not Found (HTTP 404).
x <- HTTPNotFound$new()x$do_verbose(resp)#> Error: Not Found (HTTP 404).#> - The server has not found anything matching the Request-URI. No indication is#> given of whether the condition is temporary or permanent. The 410 (Gone) status#> code SHOULD be used if the server knows, through some internally configurable#> mechanism, that an old resource is permanently unavailable and has no forwarding#> address. #> This status code is commonly used when the server does not wish to#> reveal exactly why the request has been refused, or when no other response is#> applicable.
library("httr")res <- GET("")http405(res)#> Error: Method Not Allowed (HTTP 405).
x <- HTTPMethodNotAllowed$new()x$do_verbose(res)#> Error: Method Not Allowed (HTTP 405).#> - The method specified in the Request-Line is not allowed for the resource#> identified by the Request-URI. The response MUST include an Allow header#> containing a list of valid methods for the requested resource.
fauxpasin R doing
citation(package = 'fauxpas')
find_error_class()for a user to get a
HTTP*class object with just the status code (#10)
webmockrpackage and the
behavior_typevariable in the
Errorclass object is now a private variable, and can be set with a new method
http*()S3 list methods added additional checks for response objects from
curlpackage that are simple lists, so are challenging to verify (#5)
http*methods via a generator (#11)
message_templatebehavior, see above related comment about new message template param (#8)