Skip to content

Commit

Permalink
conditional logic
Browse files Browse the repository at this point in the history
  • Loading branch information
wlandau committed Jan 28, 2025
1 parent 5fcdc3c commit 2106267
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 9 deletions.
21 changes: 14 additions & 7 deletions R/crew_controller.R
Original file line number Diff line number Diff line change
Expand Up @@ -1297,13 +1297,20 @@ crew_class_controller <- R6::R6Class(
summary$warning <- .subset2(summary, "warning") +
!anyNA(.subset2(out, "warnings"))
private$.summary <- summary
if (!is.null(error) && !anyNA(.subset2(out, "error"))) {
if (identical(error, "stop")) {
crew_error(message = .subset2(out, "error"))
} else if (identical(error, "warn")) {
crew_warning(message = .subset2(out, "error"))
}
}
has_error <- !is.null(error) &&
any(.subset2(out, "status") != "success")
throw_error <- has_error && identical(error, "stop")
throw_warning <- has_error && identical(error, "warn")
if_any(
throw_error,
crew_error(message = .subset2(out, "error")),
NULL
)
if_any(
throw_warning,
crew_warning(message = .subset2(out, "error")),
NULL
)
out
},
#' @description Pop all available task results and return them in a tidy
Expand Down
4 changes: 2 additions & 2 deletions tests/testthat/test-crew_controller.R
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ crew_test("can relay task errors as local errors", {
})
x$start()
x$push(command = stop("this is an error"), name = "warnings_and_errors")
x$wait(seconds_timeout = 5)
x$wait(seconds_timeout = 30)
expect_silent(
if_any(
isTRUE(as.logical(Sys.getenv("R_COVR", "false"))),
Expand Down Expand Up @@ -95,7 +95,7 @@ crew_test("can relay task errors as local warnings", {
})
x$start()
x$push(command = stop("this is an error"), name = "warnings_and_errors")
x$wait(seconds_timeout = 5)
x$wait(seconds_timeout = 30)
expect_silent(
if_any(
isTRUE(as.logical(Sys.getenv("R_COVR", "false"))),
Expand Down

0 comments on commit 2106267

Please sign in to comment.