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

Propagate call for error messages #416

Merged
merged 3 commits into from
Oct 21, 2024
Merged

Conversation

teunbrand
Copy link
Contributor

This PR aims to fix #379.

Briefly, it adds a call argument to range training that is used to communicate error messages.
Short demo:

devtools::load_all("~/packages/scales")
#> ℹ Loading scales

i_train_ranges <- function(x) {
  range <- ContinuousRange$new()
  range$train(x, call = current_call())
  range$range
}

i_train_ranges(1:10)
#> [1]  1 10
i_train_ranges(c("foo", "bar"))
#> Error in `i_train_ranges()`:
#> ! Discrete value supplied to a continuous scale

Created on 2023-12-22 with reprex v2.0.2

Copy link
Member

@thomasp85 thomasp85 left a comment

Choose a reason for hiding this comment

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

LGTM

@thomasp85 thomasp85 merged commit 91431a1 into r-lib:main Oct 21, 2024
12 checks passed
@teunbrand teunbrand deleted the train_calls branch October 21, 2024 09:27
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.

Improve messaging in Range R6 classes
2 participants