| 1 | # errors for bad inputs |
| 2 | |
| 3 | Code |
| 4 | vars_pull(letters, character()) |
| 5 | Condition |
| 6 | Error: |
| 7 | ! `character()` must select exactly one column. |
| 8 | Code |
| 9 | vars_pull(letters, c("a", "b")) |
| 10 | Condition |
| 11 | Error: |
| 12 | ! `c("a", "b")` must select exactly one column. |
| 13 | Code |
| 14 | vars_pull(letters, !!c("a", "b")) |
| 15 | Condition |
| 16 | Error: |
| 17 | ! `!!c("a", "b")` must select exactly one column. |
| 18 | Code |
| 19 | vars_pull(letters, aa) |
| 20 | Condition |
| 21 | Error: |
| 22 | ! object 'aa' not found |
| 23 | Code |
| 24 | vars_pull(letters, 0) |
| 25 | Condition |
| 26 | Error: |
| 27 | ! Can't extract column with `0`. |
| 28 | x Subscript `0` must be a positive location, not 0. |
| 29 | Code |
| 30 | vars_pull(letters, 100) |
| 31 | Condition |
| 32 | Error: |
| 33 | ! Can't extract columns past the end. |
| 34 | i Location 100 doesn't exist. |
| 35 | i There are only 26 columns. |
| 36 | Code |
| 37 | vars_pull(letters, -100) |
| 38 | Condition |
| 39 | Error: |
| 40 | ! Can't extract columns past the end. |
| 41 | i Location 100 doesn't exist. |
| 42 | i There are only 26 columns. |
| 43 | Code |
| 44 | vars_pull(letters, -Inf) |
| 45 | Condition |
| 46 | Error: |
| 47 | ! Can't extract column with `-Inf`. |
| 48 | x Can't convert from `-Inf` <double> to <integer> due to loss of precision. |
| 49 | Code |
| 50 | vars_pull(letters, TRUE) |
| 51 | Condition |
| 52 | Error: |
| 53 | ! Can't extract column with `TRUE`. |
| 54 | x `TRUE` must be numeric or character, not `TRUE`. |
| 55 | Code |
| 56 | vars_pull(letters, NA) |
| 57 | Condition |
| 58 | Error: |
| 59 | ! Can't extract column with `NA`. |
| 60 | x Subscript `NA` must be a location, not an integer `NA`. |
| 61 | Code |
| 62 | vars_pull(letters, na_int) |
| 63 | Condition |
| 64 | Error: |
| 65 | ! Can't extract column with `na_int`. |
| 66 | x Subscript `na_int` must be a location, not an integer `NA`. |
| 67 | Code |
| 68 | vars_pull(letters, "foo") |
| 69 | Condition |
| 70 | Error: |
| 71 | ! Can't extract columns that don't exist. |
| 72 | x Column `foo` doesn't exist. |
| 73 | |
| 74 | # gives informative error if quosure is missing |
| 75 | |
| 76 | Code |
| 77 | f() |
| 78 | Condition |
| 79 | Error in `f()`: |
| 80 | ! `var` is absent but must be supplied. |
| 81 | |
| 82 | # vars_pull() has informative errors |
| 83 | |
| 84 | Code |
| 85 | # # vars_pull() instruments base errors |
| 86 | (expect_error(vars_pull(letters, foobar), "")) |
| 87 | Output |
| 88 | <error/rlang_error> |
| 89 | Error: |
| 90 | ! object 'foobar' not found |
| 91 | |
| 92 | # vars_pull() errors mention correct calls |
| 93 | |
| 94 | Code |
| 95 | (expect_error(vars_pull(letters, f()))) |
| 96 | Output |
| 97 | <error/rlang_error> |
| 98 | Error in `f()`: |
| 99 | ! foo |
| 100 | |
| 101 | # vars_pull() produces correct backtraces |
| 102 | |
| 103 | Code |
| 104 | print(expect_error(vars_pull(letters, f(base = TRUE)))) |
| 105 | Output |
| 106 | <error/rlang_error> |
| 107 | Error: |
| 108 | i In argument: `f(base = TRUE)`. |
| 109 | Caused by error in `h()`: |
| 110 | ! foo |
| 111 | --- |
| 112 | Backtrace: |
| 113 | x |
| 114 | 1. +-base::print(expect_error(vars_pull(letters, f(base = TRUE)))) |
| 115 | 2. +-testthat::expect_error(vars_pull(letters, f(base = TRUE))) |
| 116 | 3. | \-testthat:::expect_condition_matching(...) |
| 117 | 4. | \-testthat:::quasi_capture(...) |
| 118 | 5. | +-testthat (local) .capture(...) |
| 119 | 6. | | \-base::withCallingHandlers(...) |
| 120 | 7. | \-rlang::eval_bare(quo_get_expr(.quo), quo_get_env(.quo)) |
| 121 | 8. +-tidyselect::vars_pull(letters, f(base = TRUE)) |
| 122 | 9. | +-tidyselect:::with_chained_errors(...) |
| 123 | 10. | | \-base::withCallingHandlers(...) |
| 124 | 11. | \-rlang::eval_tidy(expr, set_names(seq_along(vars), vars)) |
| 125 | 12. \-tidyselect (local) f(base = TRUE) |
| 126 | 13. \-tidyselect (local) g(base) |
| 127 | 14. \-tidyselect (local) h(base) |
| 128 | 15. \-base::stop("foo") |
| 129 | Code |
| 130 | print(expect_error(vars_pull(letters, f(base = FALSE)))) |
| 131 | Output |
| 132 | <error/rlang_error> |
| 133 | Error: |
| 134 | i In argument: `f(base = FALSE)`. |
| 135 | Caused by error in `h()`: |
| 136 | ! foo |
| 137 | --- |
| 138 | Backtrace: |
| 139 | x |
| 140 | 1. +-base::print(expect_error(vars_pull(letters, f(base = FALSE)))) |
| 141 | 2. +-testthat::expect_error(vars_pull(letters, f(base = FALSE))) |
| 142 | 3. | \-testthat:::expect_condition_matching(...) |
| 143 | 4. | \-testthat:::quasi_capture(...) |
| 144 | 5. | +-testthat (local) .capture(...) |
| 145 | 6. | | \-base::withCallingHandlers(...) |
| 146 | 7. | \-rlang::eval_bare(quo_get_expr(.quo), quo_get_env(.quo)) |
| 147 | 8. +-tidyselect::vars_pull(letters, f(base = FALSE)) |
| 148 | 9. | +-tidyselect:::with_chained_errors(...) |
| 149 | 10. | | \-base::withCallingHandlers(...) |
| 150 | 11. | \-rlang::eval_tidy(expr, set_names(seq_along(vars), vars)) |
| 151 | 12. \-tidyselect (local) f(base = FALSE) |
| 152 | 13. \-tidyselect (local) g(base) |
| 153 | 14. \-tidyselect (local) h(base) |
| 154 |