Skip to content

Commit c52241e

Browse files
committed
fix: catches by Dmitry
1 parent e412b8f commit c52241e

File tree

1 file changed

+4
-14
lines changed

1 file changed

+4
-14
lines changed

R/cache.R

Lines changed: 4 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ cache_environ$epidatr_cache <- NULL
4949
#' )
5050
#' }
5151
#'
52-
#' @param dir the directory in which the cache is stored. By default, this is `tools::R_user_dir()` if on R 4.0+, but must be specified for earlier versions of R. The environmental variable is `EPIDATR_CACHE_DIR`
52+
#' @param cache_dir the directory in which the cache is stored. By default, this is `tools::R_user_dir()` if on R 4.0+, but must be specified for earlier versions of R. The path can be either relative or absolute. The environmental variable is `EPIDATR_CACHE_DIR`
5353
#' @param days the maximum length of time in days to keep any particular cached call. By default this is `1`. The environmental variable is `EPIDATR_CACHE_MAX_AGE_DAYS`
5454
#' @param max_size the size of the entire cache, in MB, at which to start pruning entries. By default this is `1024`, or 1GB. The environmental variable is `EPIDATR_CACHE_MAX_SIZE_MB`.
5555
#' @param logfile where cachem's log of transactions is stored, relative to the cache directory. By default, it is `"logfile.txt"`. The environmental variable is `EPIDATR_CACHE_LOGFILE`.
@@ -67,7 +67,7 @@ set_cache <- function(cache_dir = NULL,
6767
# earlier version, so no tools
6868
cache_dir <- Sys.getenv("EPIDATR_CACHE_DIR")
6969
if (cach_dir == "") {
70-
abort("no valid EPIDATR_CACHE_DIR")
70+
cli::cli_abort("no valid EPIDATR_CACHE_DIR", class = "epidatr_cache_error")
7171
}
7272
}
7373
stopifnot(is.character(cache_dir))
@@ -164,7 +164,8 @@ check_is_recent <- function(dates, max_age) {
164164
#' the guts of caching, its interposed between fetch and the specific fetch methods. Internal method only.
165165
#'
166166
#' @param call the `epidata_call` object
167-
#' @inheritParams fetch
167+
#' @param fetch_args the args list for fetch as generated by [fetch_args_list()]
168+
#' @keywords internal
168169
#' @import cachem openssl
169170
cache_epidata_call <- function(epidata_call, fetch_args = fetch_args_list()) {
170171
as_of_cachable <- (!is.null(epidata_call$params$as_of) && epidata_call$params$as_of != "*")
@@ -213,14 +214,3 @@ cache_epidata_call <- function(epidata_call, fetch_args = fetch_args_list()) {
213214
}
214215
return(fetched)
215216
}
216-
217-
# debugonce(cache_epidata_call)
218-
# thing <- covidcast(
219-
# source = "jhu-csse",
220-
# signals = "confirmed_7dav_incidence_prop",
221-
# geo_type = "state",
222-
# time_type = "day",
223-
# geo_values = "ca,fl",
224-
# time_values = epirange(20200601, 20200801),
225-
# as_of = "20230101",
226-
# )

0 commit comments

Comments
 (0)