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

add conditionMessage method for recipes_errors #1080

Closed
simonpcouch opened this issue Jan 20, 2023 · 1 comment · Fixed by #1091
Closed

add conditionMessage method for recipes_errors #1080

simonpcouch opened this issue Jan 20, 2023 · 1 comment · Fixed by #1091
Labels
next release 🚀 upkeep maintenance, infrastructure, and similar

Comments

@simonpcouch
Copy link
Contributor

I’m very much appreciating recipes pointing out which step errors occurred in following #1069. We unfortunately don’t get the benefits of those changes in tune (and possibly other packages that need to catch and rethrow errors from recipes, see tidymodels/tune#599), as dispatch falls back to the rlang_error method for conditionMessage():

library(recipes)

data("ames", package = "modeldata")

err <- try(
  recipe(~., data = ames) |>
  step_novel(Neighborhood, new_level = "Gilbert") |>
  prep()
)
#> Error in step_novel() : 
#> Caused by error in `prep()`:
#> ! Columns already contain the new level: Neighborhood

err_cnd <- attr(err, "condition")

class(err_cnd)
#> [1] "recipes_error_step" "recipes_error"      "rlang_error"       
#> [4] "error"              "condition"

conditionMessage(err_cnd)
#> [1] "\nCaused by error in `prep()`:\n! Columns already contain the new level: Neighborhood"

Could we add a conditionMessage method that precedes the current conditionMessage() output with “Error in step_*”?

Created on 2023-01-20 with reprex v2.0.2

@github-actions
Copy link

github-actions bot commented Mar 7, 2023

This issue has been automatically locked. If you believe you have found a related problem, please file a new issue (with a reprex https://reprex.tidyverse.org) and link to this issue.

@github-actions github-actions bot locked and limited conversation to collaborators Mar 7, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
next release 🚀 upkeep maintenance, infrastructure, and similar
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants