View source: R/response-status.r
stop_for_status | R Documentation |
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.
stop_for_status(x, task = NULL)
warn_for_status(x, task = NULL)
message_for_status(x, task = NULL)
x |
a response, or numeric http code (or other object with
|
task |
The text of the message: either |
If request was successful, the response (invisibly). Otherwise,
raised a classed http error or warning, as generated by
http_condition()
http_status()
and
http://en.wikipedia.org/wiki/Http_status_codes
for more information
on http status codes.
Other response methods:
content()
,
http_error()
,
http_status()
,
response()
## Not run:
x <- GET("http://httpbin.org/status/200")
stop_for_status(x) # nothing happens
warn_for_status(x)
message_for_status(x)
x <- GET("http://httpbin.org/status/300")
stop_for_status(x)
warn_for_status(x)
message_for_status(x)
x <- GET("http://httpbin.org/status/404")
stop_for_status(x)
warn_for_status(x)
message_for_status(x)
# You can provide more information with the task argument
warn_for_status(x, "download spreadsheet")
message_for_status(x, "download spreadsheet")
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.