Skip to content

Improve tab_footnote() error message #1638

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

Merged
merged 6 commits into from
Apr 25, 2024
Merged

Conversation

olivroy
Copy link
Collaborator

@olivroy olivroy commented Apr 25, 2024

Summary

Basically uses withCallingHandlers() to give more precise location.

These are probably already tested by I used snapshots to display the user-facing messages. Tried to use tidyverse style guide + cli pluralization when possible.

The reprex in #475 now prints.

image

It mentions which footnote it was to be able to find it more easily + the offending function where column selection couldn't be resolved.

approach adding a bunch of call for error chaining.

For mentioning the function, you can see that I added manually the name of the function for better display (there were just a couple of instances.

TIL this in case it can be helpful!

f <- function(x) {
  g(x)
}

f2 <- function(x) {
  g(x, call = call("my_fn"))
}
f3 <- function(x) {
  f_user_face <- "my_fn"
  g(x, call = call(f_user_face))
  
}

g <- function(x, call = rlang::caller_env()) {
  
  cli::cli_abort("{x}", call = call)
}

f(23)
#> Error in `f()`:
#> ! 23

f2(23)
#> Error in `my_fn()`:
#> ! 23

f3(23)
#> Error in `my_fn()`:
#> ! 23

Created on 2024-04-25 with reprex v2.1.0

Related GitHub Issues and PRs

Fixes #475

Checklist

q: will the message work if the footnote is gr or md?

@olivroy olivroy changed the title Error2 Improve tab_footnote() error message Apr 25, 2024
@rich-iannone rich-iannone self-requested a review April 25, 2024 14:42
@rich-iannone
Copy link
Member

Thank you for contributing this! Will review shortly, then merge.

Copy link
Member

@rich-iannone rich-iannone left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

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.

"Error in .f(.x[[i]], ...) : object 'values_1' not found" should be updated to more readable error
2 participants