Skip to content

Commit

Permalink
Improve error messages
Browse files Browse the repository at this point in the history
  • Loading branch information
gaborcsardi committed Sep 22, 2022
1 parent 5c3ca20 commit a1d747a
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 5 deletions.
4 changes: 2 additions & 2 deletions R/inline.R
Original file line number Diff line number Diff line change
Expand Up @@ -299,12 +299,12 @@ make_cmd_transformer <- function(values) {
} else {
expr <- parse(text = code, keep.source = FALSE) %??%
cli_error(paste(
"Error while parsing cli {.code {{}}} expression:",
"Could not parse cli {.code {{}}} expression:",
"{.code {abbrev(code, 20)}}."
))
res <- eval(expr, envir = envir) %??%
cli_error(paste(
"Error while evaluating cli {.code {{}}} expression:",
"Could not evaluate cli {.code {{}}} expression:",
"{.code {abbrev(code, 20)}}."
))

Expand Down
2 changes: 1 addition & 1 deletion tests/testthat/_snaps/inline-2.md
Original file line number Diff line number Diff line change
Expand Up @@ -394,7 +394,7 @@
cli_text("xx {1 + 'a'} yy")
Condition
Error:
! Error while evaluating cli `{}` expression: `1 + 'a'`.
! Could not evaluate cli `{}` expression: `1 + 'a'`.
Caused by error:
! non-numeric argument to binary operator

2 changes: 1 addition & 1 deletion tests/testthat/_snaps/new-r/inline-2.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
cli_text("xx {__cannot-parse-this__} yy")
Condition
Error:
! Error while parsing cli `{}` expression: `__cannot-parse-th...`.
! Could not parse cli `{}` expression: `__cannot-parse-th...`.
Caused by error:
! <text>:1:2: unexpected input
1: __
Expand Down
2 changes: 1 addition & 1 deletion tests/testthat/_snaps/progress-along.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
cli_with_ticks(fun())
Condition
Warning in `value[[3L]]()`:
cli progress bar update failed: ! Error while evaluating cli `{}` expression: `1+''`.
cli progress bar update failed: ! Could not evaluate cli `{}` expression: `1+''`.
Caused by error in `1 + ""`:
! non-numeric argument to binary operator
Output
Expand Down

0 comments on commit a1d747a

Please sign in to comment.