Skip to content

FR: Make input-issue errors for vec_as_names with repair = "check_unique" consistently user-facing #2067

@eutwt

Description

@eutwt

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions