You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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).
The text was updated successfully, but these errors were encountered:
Right now, to someone unfamiliar with how
loadCaches
is implemented, the error message that comes back from a nonexistent cache file will be confusing.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. ThenloadCaches
could use that function to check for the file and provide an more informative message about the missing cache file before ever calling intosimpleCache
.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 inloadCaches
and once insimpleCache
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 aloadCaches
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 withinsimpleCache
, I don't want to simply wrap the call into it fromloadCaches
in atryCatch
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 withinsimpleCache
and provide the appropriate missing file exception message if we intercept that error type from the call intosimpleCache
.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).The text was updated successfully, but these errors were encountered: