http_stop_for_status: Throw R errors for HTTP errors

View source: R/http.R

http_stop_for_statusR Documentation

Throw R errors for HTTP errors

Description

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.

Usage

http_stop_for_status(resp)

Arguments

resp

HTTP response from http_get(), http_head(), etc.

Value

The HTTP response invisibly, if it is considered successful. Otherwise an error is thrown.

Examples


afun <- async(function() {
  http_get("https://eu.httpbin.org/status/404")$
    then(http_stop_for_status)
})

tryCatch(synchronise(afun()), error = function(e) e)


r-lib/async documentation built on March 24, 2024, 6:20 p.m.