Skip to content

Commit

Permalink
Use info bullet in chained errors
Browse files Browse the repository at this point in the history
  • Loading branch information
lionel- committed Oct 14, 2022
1 parent c9c8539 commit 1822141
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 15 deletions.
4 changes: 2 additions & 2 deletions R/conditions.R
Expand Up @@ -19,9 +19,9 @@ with_chained_errors <- function(expr, action, call, eval_expr = NULL) {
msg <- ""
} else {
code <- as_label(eval_expr)
msg <- cli::format_inline("Problem while evaluating {.code {code}}.")
msg <- cli::format_inline("In argument: {.code {code}}.")
}
abort(msg, call = call, parent = cnd)
cli::cli_abort(c("i" = msg), call = call, parent = cnd)
}
)
}
Expand Down
2 changes: 1 addition & 1 deletion man/all_of.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions tests/testthat/_snaps/eval-select.md
Expand Up @@ -92,7 +92,7 @@
Output
<error/rlang_error>
Error in `select_loc()`:
! Problem while evaluating `f(base = TRUE)`.
i In argument: `f(base = TRUE)`.
Caused by error in `h()`:
! foo
---
Expand All @@ -107,7 +107,7 @@
Output
<error/rlang_error>
Error in `select_loc()`:
! Problem while evaluating `f(base = FALSE)`.
i In argument: `f(base = FALSE)`.
Caused by error in `h()`:
! foo
---
Expand All @@ -124,7 +124,7 @@
Output
<error/rlang_error>
Error in `select_loc()`:
! Problem while evaluating `1 + ""`.
i In argument: `1 + ""`.
Caused by error in `1 + ""`:
! non-numeric argument to binary operator
Code
Expand All @@ -133,7 +133,7 @@
Output
<error/rlang_error>
Error in `select_loc()`:
! Problem while evaluating `f()`.
i In argument: `f()`.
Caused by error in `1 + ""`:
! non-numeric argument to binary operator

2 changes: 1 addition & 1 deletion tests/testthat/_snaps/eval-walk.md
Expand Up @@ -61,7 +61,7 @@
select_loc(iris, eval_tidy(foobar))
Condition
Error in `select_loc()`:
! Problem while evaluating `eval_tidy(foobar)`.
i In argument: `eval_tidy(foobar)`.
Caused by error:
! object 'foobar' not found

Expand Down
10 changes: 5 additions & 5 deletions tests/testthat/_snaps/helpers-vector.md
Expand Up @@ -4,7 +4,7 @@
select_loc(letters2, all_of(c("a", "bar", "c")), strict = FALSE)
Condition
Error in `select_loc()`:
! Problem while evaluating `all_of(c("a", "bar", "c"))`.
i In argument: `all_of(c("a", "bar", "c"))`.
Caused by error in `all_of()`:
! Can't subset elements that don't exist.
x Element `bar` doesn't exist.
Expand All @@ -28,7 +28,7 @@
Output
<error/rlang_error>
Error in `select_loc()`:
! Problem while evaluating `all_of(TRUE)`.
i In argument: `all_of(TRUE)`.
Caused by error in `all_of()`:
! Must subset elements with a valid subscript vector.
x Subscript has the wrong type `logical`.
Expand All @@ -38,7 +38,7 @@
Output
<error/rlang_error>
Error in `select_loc()`:
! Problem while evaluating `any_of(TRUE)`.
i In argument: `any_of(TRUE)`.
Caused by error in `any_of()`:
! Must subset elements with a valid subscript vector.
x Subscript has the wrong type `logical`.
Expand All @@ -48,7 +48,7 @@
Output
<error/rlang_error>
Error in `select_loc()`:
! Problem while evaluating `any_of(is.factor)`.
i In argument: `any_of(is.factor)`.
Caused by error in `any_of()`:
! Must subset elements with a valid subscript vector.
x Subscript has the wrong type `function`.
Expand All @@ -58,7 +58,7 @@
Output
<error/rlang_error>
Error in `select_loc()`:
! Problem while evaluating `all_of(is.factor)`.
i In argument: `all_of(is.factor)`.
Caused by error in `all_of()`:
! Must subset elements with a valid subscript vector.
x Subscript has the wrong type `function`.
Expand Down
4 changes: 2 additions & 2 deletions tests/testthat/_snaps/vars-pull.md
Expand Up @@ -106,7 +106,7 @@
Output
<error/rlang_error>
Error:
! Problem while evaluating `f(base = TRUE)`.
i In argument: `f(base = TRUE)`.
Caused by error in `h()`:
! foo
---
Expand All @@ -121,7 +121,7 @@
Output
<error/rlang_error>
Error:
! Problem while evaluating `f(base = FALSE)`.
i In argument: `f(base = FALSE)`.
Caused by error in `h()`:
! foo
---
Expand Down

0 comments on commit 1822141

Please sign in to comment.