http_error

0th

Percentile

Take action on http error.

Converts http errors to R errors or warnings - these should always be used whenever you're creating requests inside a function, so that the user knows why a request has failed.

Usage
stop_for_status(x)

warn_for_status(x)

Arguments
x
a request object
Value

  • If request was successful, an invisible TRUE. Otherwise, raised a classed http error or warning, as generated by http_condition

See Also

http_status and http://en.wikipedia.org/wiki/Http_status_codes for more information on http status codes.

Other response methods: content, parsed_content, text_content; http_status; response; url_ok; url_success

Aliases
  • http_error
  • stop_for_status
  • warn_for_status
Examples
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)
Documentation reproduced from package httr, version 0.6.1, License: MIT + file LICENSE

Community examples

Looks like there are no examples yet.