httr (version 0.2)

http_error: Take action on http error.

Description

Converts http errors to R errors or warnings - this is useful if you want to ensure the appropriate action is taken when an http request fails. See http_status or http://en.wikipedia.org/wiki/Http_status_codes for more information on http status codes.

Usage

stop_for_status(x)

warn_for_status(x)

Arguments

x
a request object

See Also

Other response methods: content, http_status, response, url_ok, url_success

Examples

Run this code
x <- GET("http://httpbin.org/status/200")
stop_for_status(x) # nothing happens
warn_for_status(x)

x <- GET("http://httpbin.org/status/300")
stop_for_status(x)
warn_for_status(x)

x <- GET("http://httpbin.org/status/404")
stop_for_status(x)
warn_for_status(x)

Run the code above in your browser using DataLab