Skip to contents

Checks if cache folder exists, if not returns an informative message

Usage

tw_check_cache_folder()

Value

If the cache folder exists, returns TRUE. Otherwise throws an error.

Examples


# If cache folder does not exist, it throws an error
tryCatch(tw_check_cache_folder(),
  error = function(e) {
    return(e)
  }
)
#> <error/rlang_error>
#> Error in `tw_check_cache_folder()`:
#> ! Cache folder does not exist.
#>  Set it with `tw_set_cache_folder()` and create it with
#>   `tw_create_cache_folder()`.
#> ---
#> Backtrace:
#>      
#>   1. └─pkgdown::build_site_github_pages(new_process = FALSE, install = FALSE)
#>   2.   └─pkgdown::build_site(...)
#>   3.     └─pkgdown:::build_site_local(...)
#>   4.       └─pkgdown::build_reference(...)
#>   5.         └─purrr::map(...)
#>   6.           └─purrr:::map_("list", .x, .f, ..., .progress = .progress)
#>   7. ─purrr:::with_indexed_errors(...)
#>   8. └─base::withCallingHandlers(...)
#>   9. purrr:::call_with_cleanup(...)
#>  10.             └─pkgdown (local) .f(.x[[i]], ...)
#>  11. base::withCallingHandlers(...)
#>  12.               └─pkgdown:::data_reference_topic(...)
#>  13.                 └─pkgdown:::run_examples(...)
#>  14.                   └─pkgdown:::highlight_examples(code, topic, env = env)
#>  15.                     └─downlit::evaluate_and_highlight(...)
#>  16.                       └─evaluate::evaluate(code, child_env(env), new_device = TRUE, output_handler = output_handler)
#>  17.                         └─evaluate:::evaluate_call(...)
#>  18. ─evaluate (local) timing_fn(...)
#>  19. ─evaluate (local) handle(...)
#>  20. └─base::try(f, silent = TRUE)
#>  21. └─base::tryCatch(...)
#>  22. └─base (local) tryCatchList(expr, classes, parentenv, handlers)
#>  23. └─base (local) tryCatchOne(expr, names, parentenv, handlers[[1L]])
#>  24. └─base (local) doTryCatch(return(expr), name, parentenv, handler)
#>  25. ─base::withCallingHandlers(...)
#>  26. ─base::withVisible(...)
#>  27.                           └─evaluate:::eval_with_user_handlers(expr, envir, enclos, user_handlers)
#>  28.                             └─base::eval(expr, envir, enclos)
#>  29.                               └─base::eval(expr, envir, enclos)
#>  30. ─base::tryCatch(...)
#>  31. └─base (local) tryCatchList(expr, classes, parentenv, handlers)
#>  32. └─base (local) tryCatchOne(expr, names, parentenv, handlers[[1L]])
#>  33. └─base (local) doTryCatch(return(expr), name, parentenv, handler)
#>  34.                                 └─tidywikidatar::tw_check_cache_folder()

# Create cache folder
tw_set_cache_folder(path = fs::path(
  tempdir(),
  "tw_cache_folder"
))
tw_create_cache_folder(ask = FALSE)

tw_check_cache_folder()
#> [1] TRUE