api_error_handler {request} | R Documentation |
Error handler
Description
Error handler
Usage
api_error_handler(.data, fun)
Arguments
.data |
Result of a call to |
fun |
A function, either defined in the session, or a function available in loaded or name-spaced packges |
See Also
Other dsl: api_body
,
api_config
, api_query
,
api
, auth
Examples
## Not run:
# Use functions from httr
api('https://api.github.com/') %>%
api_error_handler(stop_for_status)
api('https://api.github.com/') %>%
api_error_handler(warn_for_status)
# Custom error handling functions
my_stop <- function(x) {
if (x$status > 200) {
warning("nope, try again", call. = FALSE)
}
}
api("http://httpbin.org/status/404") %>%
api_error_handler(my_stop)
## End(Not run)
[Package request version 0.1.0 Index]