Skip to content

Commit

Permalink
Always pass a string to cli_abort()
Browse files Browse the repository at this point in the history
  • Loading branch information
lionel- committed Oct 25, 2024
1 parent 55d0a98 commit 7f3e858
Showing 1 changed file with 15 additions and 10 deletions.
25 changes: 15 additions & 10 deletions R/eval-walk.R
Original file line number Diff line number Diff line change
Expand Up @@ -108,19 +108,24 @@ ensure_named <- function(pos,
error_arg = NULL,
call = caller_env()) {
check_empty(pos, allow_empty, error_arg, call = call)


if (!allow_rename && any(names2(pos) != "")) {
msg <- "Can't rename variables in this context."
# Add more context if error_arg is supplied.
if (!is.null(error_arg)) {
msg <- c(msg, "i" = "{.arg {error_arg}} can't be renamed.")
if (is.null(error_arg)) {
cli::cli_abort(
"Can't rename variables in this context.",
class = "tidyselect:::error_disallowed_rename",
call = call
)
} else {
cli::cli_abort(
c(
"Can't rename variables in this context.",
i = "{.arg {error_arg}} can't be renamed."
),
class = "tidyselect:::error_disallowed_rename",
call = call
)
}
cli::cli_abort(
msg,
class = "tidyselect:::error_disallowed_rename",
call = call
)
}

nms <- names(pos) <- names2(pos)
Expand Down

0 comments on commit 7f3e858

Please sign in to comment.