Skip to contents

Treats a NULL argument as "not supplied". Raises an error unless exactly one argument in ... is non-NULL.

Usage

assert_exactly_one(..., call = rlang::caller_env())

Arguments

...

Two or more arguments to check, typically optional parameters of the calling function that default to NULL.

call

Environment used as the error's call context. Defaults to the calling function, so errors point at the user's code.

Value

NULL, invisibly.

Examples

connect <- function(url = NULL, socket = NULL) {
  assert_exactly_one(url, socket)
  "ok"
}
connect(url = "localhost")
#> [1] "ok"