assert_no_null_arguments: Assert function arguments are not null.

View source: R/assertions.R

assert_no_null_argumentsR Documentation

Assert function arguments are not null.

Description

Sometimes a NULL argument allows a the function to proceed without error, but produces unhelpful, NULL results. This allows the user to reject functions called with NULL arguments if they'll be problematic.

Usage

assert_no_null_arguments(as_list_env = NULL)

Arguments

as_list_env

[list] as_list_env = as.list(environment()) - default calling environment one level up the call stack

Value

[std_err] console output of missing arguments

Examples

test_fun <- function(arg_a){return(5 *arg_a)}
test_fun(NULL) # produces NULL, but maybe you prefer an error
test_fun2 <- function(arg_b){assert_no_null_arguments(); return(5 * arg_b)}
test_fun2(NULL) # produces an error rather than NULL
test_fun2() # informs user of _all_ missing arguments rather than only the first missing arg found (base R behavior)

epi-sam/SamsElves documentation built on June 12, 2025, 7 a.m.