Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: provide a stack trace for fatal errors in chunk #2369

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 18 additions & 8 deletions R/block.R
Original file line number Diff line number Diff line change
Expand Up @@ -259,14 +259,24 @@ eng_r = function(options) {
} else if (cache.exists && isFALSE(options$cache.rebuild)) {
cache$output(options$hash, 'list')
} else in_input_dir(
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)
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)
}
}
)
)
if (options$cache %in% 1:2 && (!cache.exists || isTRUE(options$cache.rebuild))) {
Expand Down
Loading