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

loadCaches failure message #20

Open
vreuter opened this issue Sep 5, 2017 · 1 comment
Open

loadCaches failure message #20

vreuter opened this issue Sep 5, 2017 · 1 comment

Comments

@vreuter
Copy link
Member

vreuter commented Sep 5, 2017

Right now, to someone unfamiliar with how loadCaches is implemented, the error message that comes back from a nonexistent cache file will be confusing.

Error in doTryCatch(return(expr), name, parentenv, handler) : 
  ::Error::     No instruction or RBuild file provided.

This comes from the call into simpleCache; here are the first couple of possible improvements that come to mind:

1 -- The logic for building the path to the cache file could be pulled out of simpleCache itself, into a separate function. Then loadCaches could use that function to check for the file and provide an more informative message about the missing cache file before ever calling into simpleCache. simpleCache could also use the filepath creation function. Without additional modification, the filepath logic creation would then be executed twice (once for the existence pre-check in loadCaches and once in simpleCache itself, but since it's cheap that doesn't seem so bad). simpleCache could also provide a parameter for a filepath directly, in which case it interprets its task as a loadCaches call, or at least skips the filepath construction step if an argument is provided to that hypothetical new filepath parameter.

2 -- Since several possible stop()s are possible from within simpleCache, I don't want to simply wrap the call into it from loadCaches in a tryCatch since we couldn't assume that a nonexistent filepath was the cause of the error. We could make a custom exception class for this (and others as we saw fit) errors from within simpleCache and provide the appropriate missing file exception message if we intercept that error type from the call into simpleCache.

The first seems better to me, but I've not implemented custom exceptions in R before so am not sure how straightforward it is(n't).

@nsheff
Copy link
Member

nsheff commented Sep 5, 2017

I like number 1.

nsheff added a commit that referenced this issue Dec 18, 2017
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

2 participants