diff --git a/R/block.R b/R/block.R index 2d299ba1dc..4c46fbaedc 100644 --- a/R/block.R +++ b/R/block.R @@ -259,24 +259,14 @@ eng_r = function(options) { } else if (cache.exists && isFALSE(options$cache.rebuild)) { cache$output(options$hash, 'list') } else in_input_dir( - withCallingHandlers( - evaluate( - code, envir = env, new_device = FALSE, - keep_warning = if (is.numeric(options$warning)) TRUE else options$warning, - keep_message = if (is.numeric(options$message)) TRUE else options$message, - stop_on_error = if (is.numeric(options$error)) options$error else { - if (options$error && options$include) 0L else 2L - }, - output_handler = knit_handlers(options$render, options) - ), - error = function (cnd) { - if (xfun::pkg_available('rlang', '1.0.0')) { - rlang::abort(paste0("Error in chunk ", options$label), parent = cnd) - } else { - signalCondition(cnd) - stop(cnd) - } - } + evaluate( + code, envir = env, new_device = FALSE, + keep_warning = if (is.numeric(options$warning)) TRUE else options$warning, + keep_message = if (is.numeric(options$message)) TRUE else options$message, + stop_on_error = if (is.numeric(options$error)) options$error else { + if (options$error && options$include) 0L else 2L + }, + output_handler = knit_handlers(options$render, options) ) ) if (options$cache %in% 1:2 && (!cache.exists || isTRUE(options$cache.rebuild))) { diff --git a/R/output.R b/R/output.R index ed32c44a56..fae33dee62 100644 --- a/R/output.R +++ b/R/output.R @@ -308,17 +308,14 @@ process_file = function(text, output) { if (progress && is.function(pb$update)) pb$update(i) group = groups[[i]] knit_concord$set(block = i) - res[i] = xfun:::handle_error( - withCallingHandlers( - if (tangle) process_tangle(group) else process_group(group), - error = function(e) if (xfun::pkg_available('rlang', '1.0.0')) rlang::entrace(e) - ), - function(loc) { + res[i] = withCallingHandlers( + if (tangle) process_tangle(group) else process_group(group), + error = function(cnd) { setwd(wd) write_utf8(res, output %n% stdout()) - paste0('\nQuitting from lines ', loc) - }, - if (labels[i] != '') sprintf(' [%s]', labels[i]), get_loc + loc <- if (labels[i] != '') get_loc(sprintf(' [%s]', labels[i])) else '' + rlang::abort(paste0('Quitting from lines ', loc), parent = cnd) + } ) }