Skip to content

Commit

Permalink
Fix #1354
Browse files Browse the repository at this point in the history
  • Loading branch information
wlandau committed Oct 30, 2024
1 parent baec6cd commit b8781d2
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 2 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ Description: Pipeline tools coordinate the pieces of computationally
The methodology in this package
borrows from GNU 'Make' (2015, ISBN:978-9881443519)
and 'drake' (2018, <doi:10.21105/joss.00550>).
Version: 1.8.0.9003
Version: 1.8.0.9005
License: MIT + file LICENSE
URL: https://docs.ropensci.org/targets/, https://github.com/ropensci/targets
BugReports: https://github.com/ropensci/targets/issues
Expand Down
3 changes: 2 additions & 1 deletion NEWS.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# targets 1.8.0.9004 (development)
# targets 1.8.0.9005 (development)

* Un-break workflows that use `format = "file_fast"` (#1339, @koefoeden).
* Fix deadlock in `error = "trim"` (#1340, @koefoeden).
Expand All @@ -7,6 +7,7 @@
* Allow `garbage_collection` to be a non-negative integer to control the frequency of garbage collection in a performant, convenient, unified way (#1351).
* Deprecate the `garbage_collection` argument of `tar_make()`, `tar_make_future()`, and `tar_make_clusterm()` (#1351).
* Instrument `target_run()`, `target_prepare()`, and `target_conclude()` using `autometric`.
* Avoid sending problematic error classes such as `"vctrs_error_subscript_oob"` to `rlang::abort()` (#1354, @Jiefei-Wang).

# targets 1.8.0

Expand Down
15 changes: 15 additions & 0 deletions R/utils_condition.R
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,7 @@ tar_error <- function(message, class) {
old <- options(rlang_backtrace_on_error = "none")
on.exit(options(old), add = TRUE)
message <- cli::col_red(message)
class <- safe_condition_class(class)
rlang::abort(message = message, class = class, call = tar_empty_envir)
}

Expand All @@ -137,6 +138,7 @@ tar_warning <- function(message, class) {
old <- options(rlang_backtrace_on_error = "none")
on.exit(options(old), add = TRUE)
message <- cli::col_red(message)
class <- safe_condition_class(class)
rlang::warn(message = message, class = class)
}

Expand All @@ -145,6 +147,7 @@ tar_warning <- function(message, class) {
tar_message <- function(message, class) {
old <- options(rlang_backtrace_on_error = "none")
on.exit(options(old))
class <- safe_condition_class(class)
rlang::inform(message = message, class = class)
}

Expand Down Expand Up @@ -199,3 +202,15 @@ default_error_classes <- tryCatch(
rlang::abort("msg", class = NULL),
error = function(condition) class(condition)
)

safe_condition_class <- function(class) {
while (length(class) && is_unsafe_condition_class(class)) {
class <- class[-1L] # nocov
}
class
}

is_unsafe_condition_class <- function(class) {
condition <- try(rlang::inform(message = "x", class = class), silent = TRUE)
inherits(condition, "try-error")
}

0 comments on commit b8781d2

Please sign in to comment.