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

more informative error for typo in "depends" list #292

Open
shainen opened this issue Mar 8, 2019 · 2 comments
Open

more informative error for typo in "depends" list #292

shainen opened this issue Mar 8, 2019 · 2 comments

Comments

@shainen
Copy link

shainen commented Mar 8, 2019

In the "depends" list in the "cache" function, when I put in a variable that does not exist (generally by accident), the error I get is
"Error in if (nrow(depends.hash) >= 1) { : argument is of length zero"

Unless you know the mistake you've made, its hard to tell from this error message that you've made a typo in the your "depends" variables. Would probably save some head scratching if the error was something more like
"Error, variable "x" in dependencies is not found in the current environment"

PS: Here is some code that will generate the error for me:
cache("new_var", {
x <- 56
}, depends = c("old_var"))

@KentonWhite
Copy link
Owner

I don't think this is possible. The cache code calls eval on the code in the curly braces. eval doesn't have error trapping capabilities. That is, it doesn't return a string with any errors it encountered. Instead if there is an error, the error is thrown by eval, which is what you are seeing.

@connectedblue would you have any thoughts on how to trap errors in the cache function?

@connectedblue
Copy link
Contributor

connectedblue commented Mar 28, 2019 via email

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

No branches or pull requests

3 participants