EVOLUTION-MANAGER
Edit File: stop_for_status.html
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><title>R: Take action on http error.</title> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <link rel="stylesheet" type="text/css" href="R.css" /> </head><body> <table width="100%" summary="page for stop_for_status {httr}"><tr><td>stop_for_status {httr}</td><td style="text-align: right;">R Documentation</td></tr></table> <h2>Take action on http error.</h2> <h3>Description</h3> <p>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. </p> <h3>Usage</h3> <pre> stop_for_status(x, task = NULL) warn_for_status(x, task = NULL) message_for_status(x, task = NULL) </pre> <h3>Arguments</h3> <table summary="R argblock"> <tr valign="top"><td><code>x</code></td> <td> <p>a response, or numeric http code (or other object with <code>status_code</code> method)</p> </td></tr> <tr valign="top"><td><code>task</code></td> <td> <p>The text of the message: either <code>NULL</code> or a character vector. If non-<code>NULL</code>, the error message will finish with "Failed to <code>task</code>".</p> </td></tr> </table> <h3>Value</h3> <p>If request was successful, the response (invisibly). Otherwise, raised a classed http error or warning, as generated by <code><a href="http_condition.html">http_condition()</a></code> </p> <h3>See Also</h3> <p><code><a href="http_status.html">http_status()</a></code> and <code style="white-space: pre;">http://en.wikipedia.org/wiki/Http_status_codes</code> for more information on http status codes. </p> <p>Other response methods: <code><a href="content.html">content</a>()</code>, <code><a href="http_error.html">http_error</a>()</code>, <code><a href="http_status.html">http_status</a>()</code>, <code><a href="response.html">response</a>()</code> </p> <h3>Examples</h3> <pre> 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") ## Not run: stop_for_status(x) ## End(Not run) warn_for_status(x) message_for_status(x) x <- GET("http://httpbin.org/status/404") ## Not run: stop_for_status(x) ## End(Not run) 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") </pre> <hr /><div style="text-align: center;">[Package <em>httr</em> version 1.4.2 <a href="00Index.html">Index</a>]</div> </body></html>