@@ -108,19 +108,24 @@ ensure_named <- function(pos,
108
108
error_arg = NULL ,
109
109
call = caller_env()) {
110
110
check_empty(pos , allow_empty , error_arg , call = call )
111
-
112
111
113
112
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
+ )
118
128
}
119
- cli :: cli_abort(
120
- msg ,
121
- class = " tidyselect:::error_disallowed_rename" ,
122
- call = call
123
- )
124
129
}
125
130
126
131
nms <- names(pos ) <- names2(pos )
@@ -140,10 +145,10 @@ check_empty <- function(x, allow_empty = TRUE, error_arg = NULL, call = caller_e
140
145
if (is.null(error_arg )) {
141
146
msg <- " Must select at least one item."
142
147
} 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." )
144
149
}
145
150
cli :: cli_abort(
146
- msg ,
151
+ " { msg} " ,
147
152
call = call ,
148
153
class = " tidyselect_error_empty_selection"
149
154
)
0 commit comments