HttpError: HTTP errors

View source: R/http.R

HttpErrorR Documentation

HTTP errors

Description

Special error classes for HTTP. See also as_http_error_body() for turning R errors into lists that can be returned by plumber APIs.

Usage

HttpError(message, status, ..., headers = NULL, class = NULL, call = NULL)

HttpServerError(
  message,
  status,
  ...,
  headers = NULL,
  class = NULL,
  call = NULL
)

HttpInternalServerError(
  message = "Internal Server Error",
  ...,
  headers = NULL,
  class = NULL,
  call = NULL
)

HttpServiceUnavailableError(
  message = "Service Unavailable",
  ...,
  headers = NULL,
  class = NULL,
  call = NULL,
  retry_after = NULL
)

HttpClientError(
  message,
  status,
  ...,
  headers = NULL,
  class = NULL,
  call = NULL
)

HttpBadRequestError(
  message = "Bad Request",
  ...,
  headers = NULL,
  class = NULL,
  call = NULL
)

HttpNotFoundError(
  message = "Not Found",
  ...,
  headers = NULL,
  class = NULL,
  call = NULL
)

HttpConflictError(
  message = "Conflict",
  ...,
  headers = NULL,
  class = NULL,
  call = NULL
)

Value

an error condition object with the subclasses HttpError, http_error and http_<status>. The latter two are for compatability with httr::http_condition() objects. The error conditions reflect the hirarchy, e.g. HttpServiceUnavailableError inherits from HttpServerError, HttpError, http_500, http_error.

See Also

https://tools.ietf.org/html/rfc7231#section-6

Examples

print(class(HttpServiceUnavailableError()))

tryCatch(
  stop(HttpServiceUnavailableError()),
  HttpServiceUnavailableError = function(e) print(e)
)

tryCatch(
  stop(HttpServiceUnavailableError()),
  http_503 = function(e) print(e)
)

s-fleck/exceptions documentation built on May 18, 2022, 10:57 a.m.