EVOLUTION-MANAGER
Edit File: http_condition.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: Generate a classed http condition.</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 http_condition {httr}"><tr><td>http_condition {httr}</td><td style="text-align: right;">R Documentation</td></tr></table> <h2>Generate a classed http condition.</h2> <h3>Description</h3> <p>This function generate S3 condition objects which are passed to <code><a href="../../base/html/stop.html">stop()</a></code> or <code><a href="../../base/html/warning.html">warning()</a></code> to generate classes warnings and error. These can be used in conjunction with <code><a href="../../base/html/conditions.html">tryCatch()</a></code> to respond differently to different type of failure. </p> <h3>Usage</h3> <pre> http_condition(x, type, task = NULL, call = sys.call(-1)) </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>type</code></td> <td> <p>type of condition to generate. Must be one of error, warning or message.</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> <tr valign="top"><td><code>call</code></td> <td> <p>The call stored in the condition object.</p> </td></tr> </table> <h3>Value</h3> <p>An S3 object that inherits from (e.g.) condition, <code>type</code>, http_error, http_400 and http_404. </p> <h3>See Also</h3> <p><a href="http://adv-r.had.co.nz/Exceptions-Debugging.html#condition-handling">http://adv-r.had.co.nz/Exceptions-Debugging.html#condition-handling</a> for more details about R's condition handling model </p> <h3>Examples</h3> <pre> # You can use tryCatch to take different actions based on the type # of error. Note that tryCatch will call the first handler that # matches any classes of the condition, not the best matching, so # always list handlers from most specific to least specific f <- function(url) { tryCatch(stop_for_status(GET(url)), http_404 = function(c) "That url doesn't exist", http_403 = function(c) "You need to authenticate!", http_400 = function(c) "You made a mistake!", http_500 = function(c) "The server screwed up" ) } f("http://httpbin.org/status/404") f("http://httpbin.org/status/403") f("http://httpbin.org/status/505") </pre> <hr /><div style="text-align: center;">[Package <em>httr</em> version 1.4.2 <a href="00Index.html">Index</a>]</div> </body></html>