Check that argument is supplied Throws an informative error if arg is missing.

arg_require(arg, error_arg = caller_arg(arg), error_call = caller_env())

Arguments

arg

A function argument. Must be a symbol.

error_arg

An argument name as a string. This argument will be mentioned in error messages as the input that is at the origin of a problem.

error_call

The execution environment of a currently running function, e.g. caller_env(). The function will be mentioned in error messages as the source of the error. See the call argument of abort() for more information.

See also

Examples

f <- function(x) { arg_require(x) } # Fails because `x` is not supplied try(f())
#> Error in f() : #> `x` must be supplied.
# Succeeds f(NULL)
#> [1] TRUE