Skip to content

Fix missing c/chr in preparation of cli message #169

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

Closed
brookslogan opened this issue Sep 7, 2023 · 1 comment · Fixed by #170
Closed

Fix missing c/chr in preparation of cli message #169

brookslogan opened this issue Sep 7, 2023 · 1 comment · Fixed by #170

Comments

@brookslogan
Copy link
Contributor

{cli_,}{abort,warn,inform} expect the entire message inside message; ... is used to add named fields to the condition object that they create (so you can extract extra info from, e.g., rlang::last_error()$<name>). I'm getting

Error in `warning_cnd()`:
! Conditions must have named data fields
---
Backtrace:
    ▆
 1. ├─epidatr::pub_covidcast(...)
 2. │ └─... %>% fetch(fetch_args = fetch_args) at cmu-delphi-epidatr-b5f819a/R/endpoints.R:747:2
 3. ├─epidatr::fetch(., fetch_args = fetch_args)
 4. │ └─epidatr:::cache_epidata_call(epidata_call, fetch_args = fetch_args) at cmu-delphi-epidatr-b5f819a/R/epidatacall.R:207:2
 5. │   └─cli::cli_warn(...) at cmu-delphi-epidatr-b5f819a/R/cache.R:253:6
 6. │     └─rlang::warn(format_warning(message, .envir = .envir), ...)
 7. │       └─rlang::warning_cnd(...)
 8. └─rlang::abort(message = message)

from

      cli::cli_warn("using cached results with `as_of` within the past week (or the future!). This will likely result ",
        "in an invalid cache. Consider\n",
        "1. disabling the cache for this session with `disable_cache` or permanently with environmental ",
        "variable `EPIDATR_USE_CACHE=FALSE`\n",
        "2. setting `EPIDATR_CACHE_MAX_AGE_DAYS={Sys.getenv('EPIDATR_CACHE_MAX_AGE_DAYS', unset = 1)}` to e.g. `3/24` ",
        "(3 hours).",
        .frequency = "regularly",
        .frequency_id = "cache timing issues",
        class = "cache_recent_data"
      )

Fix is just wrapping up all the message parts in a character vector using c.

@dshemetov
Copy link
Contributor

dshemetov commented Sep 7, 2023

Right, this should do it

cli::cli_warn(
  c(
    "Using cached results with `as_of` within the past week (or the future!).
    This will likely result in an invalid cache. Consider:",
    "i" = "disabling the cache for this session with `disable_cache` or
           permanently with environmental variable `EPIDATR_USE_CACHE=FALSE`",
    "i" = "setting
          `EPIDATR_CACHE_MAX_AGE_DAYS={Sys.getenv('EPIDATR_CACHE_MAX_AGE_DAYS',
          unset = 1)}` to e.g. `3/24` (3 hours)."
  ),
  .frequency = "regularly",
  .frequency_id = "cache timing issues",
  class = "cache_recent_data"
)

dsweber2 added a commit that referenced this issue Sep 7, 2023
@dsweber2 dsweber2 mentioned this issue Sep 7, 2023
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

Successfully merging a pull request may close this issue.

2 participants