Skip to content

loadCaches failure message #20

@vreuter

Description

@vreuter

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).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions