Skip to content

Commit

Permalink
Change direction for error messages
Browse files Browse the repository at this point in the history
  • Loading branch information
wlandau committed Feb 25, 2025
1 parent 239ce5b commit fd1476f
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 50 deletions.
2 changes: 1 addition & 1 deletion LICENSE.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# MIT License

Copyright (c) 2021 Eli Lilly and Company
Copyright (c) 2025 Eli Lilly and Company

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
2 changes: 1 addition & 1 deletion NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* Upload workspaces to the cloud if `tar_option_get("repository_meta")` is `"aws"` or `"gcp"`. Download them with `tar_workspace_download()` and delete them with `tar_destroy(destroy = "all")` or `tar_destroy(destroy = "cloud")`.
* Deep-copy settings when resolving `format = "auto"` (#1425, @paulseamer).
* Add `store_read_path.tar_auto()` (#1429, @paulseamer).
* Report errors concluding targets (#1435, @stemangiola).
* Improve error message that explains `iteration = "group"` branching problems.

# targets 1.10.1

Expand Down
36 changes: 2 additions & 34 deletions R/class_builder.R
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,8 @@ target_skip.tar_builder <- function(
)
}

tar_conclude_tar_builder_try <- function(target, pipeline, scheduler, meta) {
#' @export
target_conclude.tar_builder <- function(target, pipeline, scheduler, meta) {
if (package_installed("autometric (>= 0.1.0)")) {
phase <- paste("conclude:", target_get_name(target))
autometric::log_phase_set(phase = phase)
Expand All @@ -252,39 +253,6 @@ tar_conclude_tar_builder_try <- function(target, pipeline, scheduler, meta) {
error = builder_error(target, pipeline, scheduler, meta),
completed = builder_completed(target, pipeline, scheduler, meta)
)
}

#' @export
target_conclude.tar_builder <- function(target, pipeline, scheduler, meta) {
tryCatch(
tar_conclude_tar_builder_try(
target = target,
pipeline = pipeline,
scheduler = scheduler,
meta = meta
),
error = function(condition) {
name <- target_get_name(target)
message <- sprintf(
paste0(
"Cannot conclude target %s. ",
"Cannot continue the current run of the pipeline. ",
"Error concluding the target: \"%s\"."
),
name,
conditionMessage(condition)
)
if (!is.null(target$metrics$error)) {
message <- paste0(
message,
" Error running the target: \"",
target$metrics$error,
"\"."
)
}
tar_throw_run(message)
}
)
NextMethod()
}

Expand Down
14 changes: 0 additions & 14 deletions tests/testthat/test-class_builder.R
Original file line number Diff line number Diff line change
Expand Up @@ -737,17 +737,3 @@ tar_test("capture storage warnings", {
expect_equal(tar_read(x), 123L)
expect_equal(tar_meta(x)$warnings, "run_warning. storage_warning")
})

tar_test("catch error concluding target", {
skip_cran()
tar_script(
list(
tar_target(x, stop("abc"), iteration = "group", error = "continue"),
tar_target(y, x, pattern = map(x))
)
)
expect_error(
suppressWarnings(tar_make(callr_function = NULL)),
class = "tar_condition_run"
)
})

0 comments on commit fd1476f

Please sign in to comment.