-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Review error messages #5557
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
Review error messages #5557
Conversation
…)` with `expect_snapshot()`." This reverts commit 3b7dcc7.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for such a thorough review of all the error messages! The PR looks almost good to me, but if you could have a look at some of the comments that'd be swell.
Co-authored-by: Teun van den Brand <[email protected]>
I applied your suggestions. Thanks for the prompt review! On a related note, I was wondering how to make error messages look better: devtools::load_all("~/rrr-forks/ggplot2/")
#> ℹ Loading ggplot2
#> Warning: le package 'testthat' a été compilé avec la version R 4.3.2
plot <- ggplot(sf::st_polygon(list(matrix(1e3*c(1, 2, 3, 1, 1, 3, 2, 1), ncol = 2)))) +
geom_sf()
p <- plot +
scale_x_continuous(
breaks = c(1000, 2000, 3000),
labels = function(...) c("A", "B")
)
ggplot_build(p)
#> Error in `fixup_graticule_labels()`
#> ! `breaks` and `labels` along `x` direction have different lengths. Created on 2023-12-04 with reprex v2.0.2 Like, how could it show this instead?
|
I think you could 'lie' and use: cli::cli_abort({error_message}, call = scale_x$call) I call this a 'lie' because it is some coord-specific quirck that doesn't let the scale handle breaks/labels as per usual, but the scale is definitely the place where it should be fixed. |
Ok thanks. I may look into this when more PRs are merged. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Look great, thanks for tackling these messages!
Add full stops to error messages + other tweaks. (to adhere to tidyverse style guide)
Also useexpect_snapshot()
overexpect_snapshot_warning()
anderror_snapshot_error()
for consistency. (they are superseded in testthat. It allows to see more clearly what error message the user sees.I may do a transition to
expect_snapshot()
in a future PR. For the sake of having a self contained PR, I just reviewed error messages.