Skip to content

Commit

Permalink
Strip call for top-level errors
Browse files Browse the repository at this point in the history
  • Loading branch information
hadley committed Jul 10, 2024
1 parent 9034b84 commit 4483f42
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
4 changes: 4 additions & 0 deletions R/conditions.R
Original file line number Diff line number Diff line change
Expand Up @@ -54,5 +54,9 @@ sanitize_call <- function(cnd) {
if (identical(cnd$call, quote(withVisible(do)))) {
cnd$call <- NULL
}
if (identical(cnd$call, quote(eval(as.call(list(cb)), envir)))) {
cnd$call <- NULL
}

cnd
}
4 changes: 4 additions & 0 deletions tests/testthat/test-conditions.R
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@ test_that("all condition handlers first capture output", {
test_that("conditions get calls stripped", {
expect_equal(evaluate("warning('x')")[[2]]$call, NULL)
expect_equal(evaluate("stop('x')")[[2]]$call, NULL)

# including errors emitted by C
expect_equal(evaluate("mpg")[[2]]$call, NULL)
expect_equal(evaluate("3()")[[2]]$call, NULL)
})

test_that("envvar overrides keep_* arguments", {
Expand Down

0 comments on commit 4483f42

Please sign in to comment.