r-lib / rlang

Low-level API for programming with R
https://rlang.r-lib.org
Other
498 stars 136 forks source link

Consider allowing `arg = I("custom arg name")` in `stop_input_type()` #1607

Closed DavisVaughan closed 1 year ago

DavisVaughan commented 1 year ago

So you can do something like:

stop_input_type(x, "a numeric vector", arg = I(glue("Element {i} of `x`"))
#> Element 5 of `x` must be a numeric vector, not a factor.

Useful if you are mapping over a user supplied list (like if the user supplied ...) and you want to check that each one is a particular type. Otherwise I'd end up calling cli_abort() directly to completely control the error message