Skip to content

Commit

Permalink
add error results for when all are errors
Browse files Browse the repository at this point in the history
  • Loading branch information
JosiahParry committed Apr 8, 2024
1 parent f1fa461 commit b7f1837
Showing 1 changed file with 10 additions and 11 deletions.
21 changes: 10 additions & 11 deletions R/rbind-results.R
Original file line number Diff line number Diff line change
Expand Up @@ -26,17 +26,17 @@
rbind_results <- function(
x,
call = rlang::current_env(),
.ptype = data.frame()
) {

.ptype = data.frame()) {
# use for loop for side effects
# check that each element is a data.frame
for (item in x) check_data_frame(
item,
allow_null = TRUE,
call = call,
arg = rlang::caller_arg(x)
)
for (item in x) {
check_data_frame(
item,
allow_null = TRUE,
call = call,
arg = rlang::caller_arg(x)
)
}

# check if all results are sf, if so, we must return sf
return_sf <- all(vapply(x, inherits_or_null, logical(1), class = "sf"))
Expand All @@ -48,7 +48,7 @@ rbind_results <- function(
if (all(missing_elements)) {
# return empty data.frame() if all missing
# FIXME should we take a ptype here? to
return(data.frame())
return(structure(data.frame(), null_elements = are_missing))
}

if (rlang::is_installed("collapse", version = "2.0.0")) {
Expand Down Expand Up @@ -87,4 +87,3 @@ inherits_or_null <- function(x, class) {
rlang::inherits_any(x, class)
}
}

0 comments on commit b7f1837

Please sign in to comment.