abort_bad_argument: Generate helpful error messages for invalid function inputs

View source: R/utils.R

abort_bad_argumentR Documentation

Generate helpful error messages for invalid function inputs

Description

This function appears in Advanced R Chapter 8.5.2 Signalling https://adv-r.hadley.nz/conditions.html#signalling It was presumably written by Hadley Wickham. Generates a helpful error message and passes it to rlang::abort. Does not determine argument validity. Use this function inside a statement which determines that an input is invalid. Is adapted with extremely minor modifications from

Usage

abort_bad_argument(arg, must, not = NULL)

Arguments

arg

the invalid function argument

must

what a valid argument must be (e.g "numeric", or "all_models")

not

what a valid argument cannot be (e.g. "character" or "adlkfm_modelz")

Value

an error. prints the custom message to the console.


taiawu/dsfworld_package documentation built on June 18, 2024, 5:39 a.m.