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

Poor error message when "missing" format objects #114

Closed
MichaelChirico opened this issue Oct 30, 2018 · 2 comments
Closed

Poor error message when "missing" format objects #114

MichaelChirico opened this issue Oct 30, 2018 · 2 comments
Labels
tidy-dev-day 🤓 Tidyverse Developer Day rstd.io/tidy-dev-day

Comments

@MichaelChirico
Copy link
Contributor

I made the mistake not to include some of the named elements & was met with a very strange error it took me a while to figure out:

Error in as.character(.transformer(expr, env)) :
cannot coerce type 'closure' to vector of type 'character'

This is because my input was actually a named function (and even though closure should have been a dead giveaway on this I spent 10 minutes + debugging):

glue::glue_data(list(x = 1), '{x} cannot be bigger than {stop}')

I'm not sure any easy way to fix this/give a more helpful message, but if so it could save time debugging.

@jimhester jimhester added the tidy-dev-day 🤓 Tidyverse Developer Day rstd.io/tidy-dev-day label Jan 4, 2019
@jimhester
Copy link
Collaborator

We will look into this during the Tidy dev day at RStudio::conf.

I think the easiest way to fix it would be to have glue use a small wrapper around as.character() which provides a more informative error message than the default when the coercion fails.

glue/R/glue.R

Line 105 in fcdfa61

f <- function(expr) as.character(.transformer(expr, env))

ref. tidyverse error messages

@ijlyttle
Copy link
Contributor

ijlyttle commented Jan 19, 2019

claiming! first stop reprex!

jimhester pushed a commit that referenced this issue Jan 26, 2019
We now test if the string is a function and throw an error if so, with the caveat that crayon functions can be coerced to characters with `as.character()` (and are in the vignette) so we only error if that coercion fails.

Fixes #114
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
tidy-dev-day 🤓 Tidyverse Developer Day rstd.io/tidy-dev-day
Projects
None yet
Development

No branches or pull requests

3 participants