Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

http_error

Check for an http error.


Description

Check for an http error.

Usage

http_error(x, ...)

Arguments

x

Object to check. Default methods are provided for strings (which perform an HEAD() request), responses, and integer status codes.

...

Other arguments passed on to methods.

Value

TRUE if the request fails (status code 400 or above), otherwise FALSE.

See Also

Other response methods: content(), http_status(), response(), stop_for_status()

Examples

# You can pass a url:
http_error("http://www.google.com")
http_error("http://httpbin.org/status/404")

# Or a request
r <- GET("http://httpbin.org/status/201")
http_error(r)

# Or an (integer) status code
http_error(200L)
http_error(404L)

httr

Tools for Working with URLs and HTTP

v1.4.2
MIT + file LICENSE
Authors
Hadley Wickham [aut, cre], RStudio [cph]
Initial release

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.