Skip to content

Line-wrap warning and error messages from the API #119

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 Jun 5, 2023 · 1 comment · Fixed by #156
Closed

Line-wrap warning and error messages from the API #119

brookslogan opened this issue Jun 5, 2023 · 1 comment · Fixed by #156
Labels
enhancement New feature or request good first issue Good for newcomers P1 medium priority

Comments

@brookslogan
Copy link
Contributor

brookslogan commented Jun 5, 2023

Warnings and error messages forwarded from the API aren't line-wrapped and could look better.

library(epidatr)
issue_data =
  covidcast(
    data_source = "hhs", signal = "confirmed_admissions_influenza_1d",
    geo_type = "state", time_type = "day",
    geo_values = c("az","ga"),
    # all `time_value`s:
    time_values = epirange(20221201, 20221231),
    # all issues through the analysis issue
    issues = epirange(20230101, 20230102)
  ) %>%
  fetch()
#> Warning: No API key found. You will be limited to non-complex queries and encounter rate
#> limits if you proceed.
#> To avoid this, you can get your key [here] and then:
#> ℹ set the environment variable DELPHI_EPIDATA_KEY
#> ℹ set the option 'delphi.epidata.key'
#> 
#> To save your key for later sessions (and hide it from your code), you can edit
#> your .Renviron file with:
#> ℹ usethis::edit_r_environ()
#> This warning is displayed once every 8 hours.
#> Warning: epidata warning: This request exceeded the anonymous limit on selected multiples, which will be enforced starting 2023-06-21. To be exempt from this limit, authenticate your requests with a free API key, now available at https://api.delphi.cmu.edu/epidata/admin/registration_form. A temporary public key `TEMP-API-KEY-EXPIRES-2023-06-28` is available for use between now and 2023-06-28 to give you time to register or adapt your requests without this message continuing to break your systems.

Created on 2023-06-05 with reprex v2.0.2 but altered to show that we're not actually wrapping the message.

We might be able to use cli for this, but need to be careful not to use the message directly as a cli format string. (I vaguely recall fiddling with this and using the brace syntax for gluing in a string and it not doing the line wrapping though, but my memory could be bad. There might be some special cli/glue thing to enable the line wrap on interpolated strings. Or we have some internal helpers in epiprocess for line wrapping, but that's sort of backwards progress.)

@brookslogan brookslogan added enhancement New feature or request good first issue Good for newcomers labels Jun 5, 2023
@brookslogan
Copy link
Contributor Author

Hmm, maybe cli will properly wrap it. Just tried this for something else with cli::cli_abort("set prefix: {message}") and it seemed to wrap. Here, using the brace syntax is essential to interpolate the message string; see link above.

@dshemetov dshemetov added the P1 medium priority label Jul 18, 2023
@dshemetov dshemetov mentioned this issue Aug 12, 2023
37 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request good first issue Good for newcomers P1 medium priority
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants