Skip to content

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

@brookslogan

Description

@brookslogan

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

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