forked from r-lib/httr
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathhttp_error.Rd
48 lines (43 loc) · 1.24 KB
/
http_error.Rd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
% Generated by roxygen2 (4.0.2): do not edit by hand
\name{http_error}
\alias{http_error}
\alias{stop_for_status}
\alias{warn_for_status}
\title{Take action on http error.}
\usage{
stop_for_status(x)
warn_for_status(x)
}
\arguments{
\item{x}{a request object}
}
\value{
If request was successful, an invisible \code{TRUE}. Otherwise,
raised a classed http error or warning, as generated by
\code{\link{http_condition}}
}
\description{
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.
}
\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")
\dontrun{stop_for_status(x)}
warn_for_status(x)
x <- GET("http://httpbin.org/status/404")
\dontrun{stop_for_status(x)}
warn_for_status(x)
}
\seealso{
\code{\link{http_status}} and
\code{http://en.wikipedia.org/wiki/Http_status_codes} for more information
on http status codes.
Other response methods: \code{\link{content}},
\code{\link{parsed_content}}, \code{\link{text_content}};
\code{\link{http_status}}; \code{\link{response}};
\code{\link{url_ok}}; \code{\link{url_success}}
}