Skip to content

Commit

Permalink
better error catching for non-data frames
Browse files Browse the repository at this point in the history
  • Loading branch information
vincentarelbundock committed Aug 16, 2024
1 parent 081002d commit 208eb25
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
3 changes: 3 additions & 0 deletions DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ Imports:
carData,
causaldata,
cluster,
collegeScorecard,
crch,
COUNT,
DAAG,
Expand Down Expand Up @@ -95,6 +96,8 @@ Imports:
texmex,
tidyr,
tidyverse,
tsibble,
tsibbledata,
validate,
vcd,
vcdExtra,
Expand Down
6 changes: 5 additions & 1 deletion scrape.R
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,11 @@ clean_data = function(dat) {
idx <- sapply(out, function(x) class(x)[1]) != "list"
out <- out[, idx, drop = FALSE]
} else {
out = suppressWarnings(tryCatch(as.data.frame(dat), error = function(e) NULL))
if (inherits(dat, "try-error")) {
out = NULL
} else {
out = suppressWarnings(tryCatch(as.data.frame(dat), error = function(e) NULL))
}
}
if (isTRUE(nrow(out) == 0)) {
out = NULL
Expand Down

0 comments on commit 208eb25

Please sign in to comment.