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

Improve error traceback #2388

Draft
wants to merge 6 commits into
base: master
Choose a base branch
from
Draft

Improve error traceback #2388

wants to merge 6 commits into from

Conversation

cderv
Copy link
Collaborator

@cderv cderv commented Jan 15, 2025

This PR follows up on evaluate 1.0.3 work.

  • knitr does entrace all error with rlang when available. This is done now in the calling handler of evaluate, closest to the error being thrown

  • evaluate does handle already trimming the backtrace for error thrown in the code evaluated. knitr need also to do it for error happening in its value handler passed to evaluate, and calling knit_print()

    • This is done at the knit_print() level directly; But it could be done also at the value handler

      knitr/R/utils.R

      Lines 882 to 887 in 8a37857

      merge_list(default_handlers, list(
      value = function(x, visible) {
      if (visible) fun(x, options = options)
      },
      calling_handlers = c(options$calling.handlers, rlang_entrace_handler)
      ))
    • Or evaluate could also do it so that it happens for any value handler, including knitr's one.

cderv added 6 commits January 15, 2025 11:00
Due to evaluate change of logic with Restarts.
This option will be used by rlang::entrace() to find the top of the trace to use.

This is one currently in rlang calling knitr::knit_global() but it makes more sense to have it in knitr directly
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant