
Last chance! 50% off unlimited learning
Sale ends in
Throws an error if x
is missing.
check_required(x, arg = caller_arg(x), call = caller_env())
A function argument. Must be a symbol.
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.
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.
arg_match()
f <- function(x) {
check_required(x)
}
# Fails because `x` is not supplied
try(f())
# Succeeds
f(NULL)
Run the code above in your browser using DataLab