diff --git a/DESCRIPTION b/DESCRIPTION index f0986c20..bbd682c4 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -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, ). -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 diff --git a/NEWS.md b/NEWS.md index 77a896c0..30cf87b1 100644 --- a/NEWS.md +++ b/NEWS.md @@ -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). @@ -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 diff --git a/R/utils_condition.R b/R/utils_condition.R index 7667b8df..d465ac27 100644 --- a/R/utils_condition.R +++ b/R/utils_condition.R @@ -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) } @@ -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) } @@ -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) } @@ -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") +}