arg_checker <- function(x, arg = caller_arg(x), call = caller_env()) {
cli::cli_abort("{.arg {arg}} must be a thingy.", arg = arg, call = call)
}
my_function <- function(my_arg) {
arg_checker(my_arg)
}
try(my_function(NULL))
Run the code above in your browser using DataLab