Skip to contents

Checks whether an argument was supplied to ....

Usage

arg_dots_supplied(..., .msg = NULL, .call)

arg_dots_not_supplied(..., .msg = NULL, .call)

Arguments

...

the ... argument passed from a calling function. The argument is not evaluated. See Examples.

.msg

an optional alternative message to display if an error is thrown instead of the default message.

.call

the execution environment of a currently running function, e.g. .call = rlang::current_env(). The corresponding function call is retrieved and mentioned in error messages as the source of the error. Passed to err(). Set to NULL to omit call information. The default is to search along the call stack for the first user-facing function in another package, if any.

Value

Returns NULL invisibly if an error is not thrown.

Details

arg_dots_supplied() checks whether arguments were passed to the ... (i.e., "dots") argument of a function. These arguments are not evaluated. arg_dots_supplied() throws an error if ...length() is 0. It can be useful for when a function must have additional arguments. For example, arg_or() and when_supplied() use arg_dots_supplied().

arg_dots_not_supplied() checks whether no arguments were passed to ..., again without evaluating the arguments and using ...length(). It can be useful when a function appears to allow further arguments (e.g., because it is a method of a generic), but when the author does not want the user to supply them.

See also

Examples

f <- function(...) {
  arg_dots_supplied(...)
}

try(f(1)) # No error: argument supplied
try(f())  # Error!
#> Error : An argument must be supplied to `...`.