Skip to content

Commit 1f7dfa4

Browse files
committed
Always pass a string to cli_abort()
1 parent 2db8846 commit 1f7dfa4

File tree

1 file changed

+17
-12
lines changed

1 file changed

+17
-12
lines changed

R/eval-walk.R

Lines changed: 17 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -108,19 +108,24 @@ ensure_named <- function(pos,
108108
error_arg = NULL,
109109
call = caller_env()) {
110110
check_empty(pos, allow_empty, error_arg, call = call)
111-
112111

113112
if (!allow_rename && any(names2(pos) != "")) {
114-
msg <- "Can't rename variables in this context."
115-
# Add more context if error_arg is supplied.
116-
if (!is.null(error_arg)) {
117-
msg <- c(msg, "i" = "{.arg {error_arg}} can't be renamed.")
113+
if (is.null(error_arg)) {
114+
cli::cli_abort(
115+
"Can't rename variables in this context.",
116+
class = "tidyselect:::error_disallowed_rename",
117+
call = call
118+
)
119+
} else {
120+
cli::cli_abort(
121+
c(
122+
"Can't rename variables in this context.",
123+
i = "{.arg {error_arg}} can't be renamed."
124+
),
125+
class = "tidyselect:::error_disallowed_rename",
126+
call = call
127+
)
118128
}
119-
cli::cli_abort(
120-
msg,
121-
class = "tidyselect:::error_disallowed_rename",
122-
call = call
123-
)
124129
}
125130

126131
nms <- names(pos) <- names2(pos)
@@ -140,10 +145,10 @@ check_empty <- function(x, allow_empty = TRUE, error_arg = NULL, call = caller_e
140145
if (is.null(error_arg)) {
141146
msg <- "Must select at least one item."
142147
} else {
143-
msg <- "{.arg {error_arg}} must select at least one column."
148+
msg <- cli::format_inline("{.arg {error_arg}} must select at least one column.")
144149
}
145150
cli::cli_abort(
146-
msg,
151+
"{msg}",
147152
call = call,
148153
class = "tidyselect_error_empty_selection"
149154
)

0 commit comments

Comments
 (0)