diff --git a/R/subscript-loc.R b/R/subscript-loc.R index c327b40d3..d078a9ec9 100644 --- a/R/subscript-loc.R +++ b/R/subscript-loc.R @@ -541,15 +541,16 @@ cnd_body_vctrs_error_subscript_oob_location <- function(cnd, ...) { )) } cnd_body_vctrs_error_subscript_oob_name <- function(cnd, ...) { - elt <- cnd_subscript_element(cnd, capital = TRUE) + elt <- cnd_subscript_element(cnd, capital = FALSE) + elt_cap <- cnd_subscript_element(cnd, capital = TRUE) oob <- cnd$i[!cnd$i %in% cnd$names] oob_enum <- enumerate(glue::backtick(oob)) format_error_bullets(c( x = glue::glue(ngettext( length(oob), - "{elt[[1]]} {oob_enum} doesn't exist.", - "{elt[[2]]} {oob_enum} don't exist." + "Can't find {elt[[1]]} {oob_enum}.", + "Can't find {elt[[2]]} {oob_enum}.", )) )) } diff --git a/tests/testthat/_snaps/conditions.md b/tests/testthat/_snaps/conditions.md index 488facd19..9585cc890 100644 --- a/tests/testthat/_snaps/conditions.md +++ b/tests/testthat/_snaps/conditions.md @@ -23,7 +23,7 @@ Error in `vec_slice()`: ! Can't subset elements. - x Element `foo` doesn't exist. + x Can't find element `foo`. Code (expect_error(with_subscript_data(vec_slice(set_names(letters), "foo"), quote( foo)), class = "vctrs_error_subscript_oob")) @@ -31,7 +31,7 @@ Error in `vec_slice()`: ! Can't subset elements with `foo`. - x Element `foo` doesn't exist. + x Can't find element `foo`. Code (expect_error(with_subscript_data(vec_slice(set_names(letters), "foo"), quote( foo(bar))), class = "vctrs_error_subscript_oob")) @@ -39,7 +39,7 @@ Error in `vec_slice()`: ! Can't subset elements with `foo(bar)`. - x Element `foo` doesn't exist. + x Can't find element `foo`. # scalar type errors are informative diff --git a/tests/testthat/_snaps/slice-assign.md b/tests/testthat/_snaps/slice-assign.md index c820e2923..521224451 100644 --- a/tests/testthat/_snaps/slice-assign.md +++ b/tests/testthat/_snaps/slice-assign.md @@ -62,7 +62,7 @@ Error: ! Can't assign elements. - x Element `foo` doesn't exist. + x Can't find element `foo`. # must assign with proper negative locations diff --git a/tests/testthat/_snaps/slice.md b/tests/testthat/_snaps/slice.md index 4bf52fc57..a9d364f4e 100644 --- a/tests/testthat/_snaps/slice.md +++ b/tests/testthat/_snaps/slice.md @@ -80,7 +80,7 @@ Condition Error in `vec_slice()`: ! Can't subset elements with `i`. - x Element `foo` doesn't exist. + x Can't find element `foo`. --- @@ -111,7 +111,7 @@ Condition Error in `vec_slice()`: ! Can't subset elements with `i`. - x Elements `foo` and `bar` don't exist. + x Can't find elements `foo` and `bar`. --- @@ -120,7 +120,7 @@ Condition Error in `vec_slice()`: ! Can't subset elements with `i`. - x Elements `A`, `B`, `C`, `D`, `E`, etc. don't exist. + x Can't find elements `A`, `B`, `C`, `D`, `E`, etc.. # vec_init() validates `n` diff --git a/tests/testthat/_snaps/subscript-loc.md b/tests/testthat/_snaps/subscript-loc.md index e91acdcec..35dabb469 100644 --- a/tests/testthat/_snaps/subscript-loc.md +++ b/tests/testthat/_snaps/subscript-loc.md @@ -198,7 +198,7 @@ Error: ! Can't subset elements with `"foo"`. - x Element `foo` doesn't exist. + x Can't find element `foo`. Code (expect_error(vec_as_location2("foo", 1L, names = "bar"), class = "vctrs_error_subscript_oob") ) @@ -206,7 +206,7 @@ Error: ! Can't extract element with `"foo"`. - x Element `foo` doesn't exist. + x Can't find element `foo`. Code (expect_error(vec_as_location2("foo", 1L, names = "bar", call = call("baz")), class = "vctrs_error_subscript_oob")) @@ -214,7 +214,7 @@ Error in `baz()`: ! Can't extract element with `"foo"`. - x Element `foo` doesn't exist. + x Can't find element `foo`. # vec_as_location2() requires length 1 inputs @@ -897,7 +897,7 @@ Error in `vec_slice()`: ! Can't subset elements with `i`. - x Element `foo` doesn't exist. + x Can't find element `foo`. Code # With custom `arg` (expect_error(vec_as_location(30, length(letters), arg = "foo", call = call( @@ -915,7 +915,7 @@ Error in `my_function()`: ! Can't subset elements with `foo`. - x Element `foo` doesn't exist. + x Can't find element `foo`. Code # With tibble columns (expect_error(with_tibble_cols(vec_slice(set_names(letters), "foo")), class = "vctrs_error_subscript_oob") @@ -924,7 +924,7 @@ Error in `vec_slice()`: ! Can't rename columns with `foo(bar)`. - x Column `foo` doesn't exist. + x Can't find column `foo`. Code (expect_error(with_tibble_cols(vec_slice(set_names(letters), 30)), class = "vctrs_error_subscript_oob") ) @@ -951,7 +951,7 @@ Error in `vec_slice()`: ! Can't remove rows with `foo(bar)`. - x Rows `foo` and `bar` don't exist. + x Can't find rows `foo` and `bar`. Code (expect_error(with_tibble_rows(vec_slice(set_names(letters), 1:30)), class = "vctrs_error_subscript_oob") ) @@ -980,7 +980,7 @@ Error in `vec_slice()`: ! Can't select columns with `foo(bar)`. - x Columns `foo` and `bar` don't exist. + x Can't find columns `foo` and `bar`. Code (expect_error(with_tidyselect_select(vec_slice(set_names(letters), 30)), class = "vctrs_error_subscript_oob") ) @@ -1008,7 +1008,7 @@ Error in `vec_slice()`: ! Can't relocate columns with `foo(bar)`. - x Columns `foo` and `bar` don't exist. + x Can't find columns `foo` and `bar`. Code (expect_error(with_tidyselect_relocate(vec_slice(set_names(letters), 30)), class = "vctrs_error_subscript_oob"))