Status codes below 400 are considered successful, others will trigger
errors. Note that this is different from the httr
package, which
considers the 3xx status code errors as well.
http_stop_for_status(resp)
HTTP response from http_get()
, http_head()
, etc.
The HTTP response invisibly, if it is considered successful. Otherwise an error is thrown.
# \donttest{
afun <- async(function() {
http_get("https://eu.httpbin.org/status/404")$
then(http_stop_for_status)
})
tryCatch(synchronise(afun()), error = function(e) e)
#> <async error: Not Found (HTTP 404).
#> in *parent* callback of `http_get("https://eu.httpbin.org/status/404")$then` at ?/?:?:?>
# }