Skip to content

Commit

Permalink
use try instead of tryCatch (#237)
Browse files Browse the repository at this point in the history
  • Loading branch information
etiennebacher committed Aug 30, 2022
1 parent cc44ae3 commit 20c12de
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 6 deletions.
10 changes: 5 additions & 5 deletions R/data_match.R
Original file line number Diff line number Diff line change
Expand Up @@ -165,11 +165,11 @@ data_filter <- function(x, filter, ...) {
if (is.character(condition)) {
condition <- .str2lang(condition)
}
out <- tryCatch(
do.call(subset, list(x, subset = condition)),
warning = function(e) NULL,
error = function(e) NULL
)
out <- try(do.call(subset, list(x, subset = condition)), silent = TRUE)
if (inherits(out, "try-error")) {
out <- NULL
}

# any errors? Give more informative message to users
# about possible misspelled comparisons / logical conditions
if (is.null(out)) {
Expand Down
1 change: 0 additions & 1 deletion tests/testthat/test-data_match.R
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,6 @@ test_that("data_filter works like slice", {
})

test_that("data_filter gives informative message on errors", {
data(mtcars)
expect_error(
data_filter(mtcars, "mpg > 10 || cyl = 4"),
"`==`"
Expand Down

0 comments on commit 20c12de

Please sign in to comment.