| 1 |
\name{curlError} |
| 2 |
\alias{curlError} |
| 3 |
\title{Raise a warning or error about a CURL problem} |
| 4 |
\description{ |
| 5 |
This function is called to raise an error or warning |
| 6 |
that arises from a curl operation when making a request. |
| 7 |
This is called from C code that encounters the error |
| 8 |
and this function is responsible for generating the error. |
| 9 |
} |
| 10 |
\usage{ |
| 11 |
curlError(type, msg, asError = TRUE) |
| 12 |
} |
| 13 |
%- maybe also 'usage' for other objects documented here. |
| 14 |
\arguments{ |
| 15 |
\item{type}{the type of the error or a status code identifying the |
| 16 |
type of the error. Typically this is an integer value that |
| 17 |
identifies the type of the Curl error. The value corresponds |
| 18 |
to one of the enumerated value of type \code{CURLcode}.} |
| 19 |
\item{msg}{the error message, as a character vector of length 1} |
| 20 |
\item{asError}{a logical value that indicates whether to raise an |
| 21 |
error or a warning} |
| 22 |
} |
| 23 |
\value{ |
| 24 |
This calls \code{warning} or \code{stop} with the relevant condition |
| 25 |
object. |
| 26 |
The object is always of basic (S3) class |
| 27 |
\code{GenericCurlError, error, condition} |
| 28 |
or |
| 29 |
\code{GenericCurlError, warning, condition}. |
| 30 |
When the \code{type} value corresponds to a |
| 31 |
\code{CURLCode} value, the condition has the primary class given by that |
| 32 |
\code{CURLCode}'s name, e.g. \code{COULDNT_RESOLVE_HOST}, |
| 33 |
\code{TOO_MANY_REDIRECTS} (with the CURLE prefix removed). |
| 34 |
|
| 35 |
} |
| 36 |
\references{ |
| 37 |
libcurl documentation. |
| 38 |
} |
| 39 |
\author{ |
| 40 |
Duncan Temple Lang |
| 41 |
} |
| 42 |
|
| 43 |
\seealso{ |
| 44 |
\code{\link{curlPerform}} |
| 45 |
} |
| 46 |
\examples{ |
| 47 |
# This illustrates generating and catching an error. |
| 48 |
# We intentionally give a mis-spelled URL. |
| 49 |
tryCatch(curlPerform(url = "ftp.wcc.nrcs.usda.govx"), |
| 50 |
COULDNT_RESOLVE_HOST = function(x) cat("resolve problem\n"), |
| 51 |
error = function(x) cat(class(x), "got it\n")) |
| 52 |
} |
| 53 |
\keyword{programming} |
| 54 |
\keyword{IO} |
| 55 |
\concept{error handling} |
| 56 |
|