diff --git a/NEWS.md b/NEWS.md index bac6e64..f225582 100644 --- a/NEWS.md +++ b/NEWS.md @@ -21,11 +21,6 @@ In addition, it gains a `cross` argument that allows you to take the cartesian product of these arguments instead. -* `eval_select(allow_empty = FALSE)` gains a new argument to yield a better error - message in case of empty selection (@olivroy, #327) - -* `eval_select()` and `eval_relocate()` gain a new `error_arg` argument that can be specified to throw a better error message when `allow_empty = FALSE`. - * `eval_select()` and `eval_relocate()` throw a classed error message when `allow_empty = FALSE` (@olivroy, #347). # tidyselect 1.2.1 diff --git a/R/eval-relocate.R b/R/eval-relocate.R index 91b199a..86016ef 100644 --- a/R/eval-relocate.R +++ b/R/eval-relocate.R @@ -117,17 +117,14 @@ eval_relocate <- function(expr, } if (has_before) { - where <- with_rename_errors( - eval_select( - expr = before, - data = data, - env = env, - error_call = error_call, - allow_predicates = allow_predicates, - allow_rename = FALSE - ), - arg = before_arg, - error_call = error_call + where <- eval_select( + expr = before, + data = data, + env = env, + error_call = error_call, + allow_predicates = allow_predicates, + allow_rename = FALSE, + error_arg = before_arg ) where <- unname(where) @@ -138,17 +135,14 @@ eval_relocate <- function(expr, where <- min(where) } } else if (has_after) { - where <- with_rename_errors( - eval_select( - expr = after, - data = data, - env = env, - error_call = error_call, - allow_predicates = allow_predicates, - allow_rename = FALSE - ), - arg = after_arg, - error_call = error_call + where <- eval_select( + expr = after, + data = data, + env = env, + error_call = error_call, + allow_predicates = allow_predicates, + allow_rename = FALSE, + error_arg = after_arg ) where <- unname(where) @@ -181,15 +175,3 @@ eval_relocate <- function(expr, sel } - -with_rename_errors <- function(expr, arg, error_call) { - withCallingHandlers( - expr, - `tidyselect:::error_disallowed_rename` = function(cnd) { - cli::cli_abort( - "Can't rename variables when {.arg {arg}} is supplied.", - call = error_call - ) - } - ) -} diff --git a/tests/testthat/_snaps/eval-relocate.md b/tests/testthat/_snaps/eval-relocate.md index 59d7eb6..e7fb6c2 100644 --- a/tests/testthat/_snaps/eval-relocate.md +++ b/tests/testthat/_snaps/eval-relocate.md @@ -115,19 +115,23 @@ Condition Error in `relocate_loc()`: ! Can't rename variables in this context. + i In argument: `before`. Code relocate_loc(x, b, before = c(new = c), before_arg = ".before") Condition Error in `relocate_loc()`: ! Can't rename variables in this context. + i In argument: `.before`. Code relocate_loc(x, b, after = c(new = c)) Condition Error in `relocate_loc()`: ! Can't rename variables in this context. + i In argument: `after`. Code relocate_loc(x, b, after = c(new = c), after_arg = ".after") Condition Error in `relocate_loc()`: ! Can't rename variables in this context. + i In argument: `.after`.