vctrs
vctrs copied to clipboard
FR: Make input-issue errors for vec_as_names with repair = "check_unique" consistently user-facing
It's convenient to use vec_as_names(x, repair = "check_uniqe") to validate that the value of an argument can be used as a name, and surface an informative message to the user if not. But in some cases, namely when x is NA or the wrong class, the message feels more oriented towards the developer of user_func() than the user. My suggestion is that the last two error messages below should be more like the first.
user_func <- function(x) {
vctrs::vec_as_names(x, repair = "check_unique")
}
# mentions user_func(), not names repair function
user_func('')
#> Error in `user_func()`:
#> ! Names can't be empty.
#> ✖ Empty name found at location 1.
# mentions names repair function
user_func(NA_character_)
#> Error:
#> ! Names repair functions can't return `NA` values.
user_func(1)
#> Error:
#> ! Names repair functions must return a character vector.
Created on 2025-10-15 with reprex v2.1.1