Skip to content

Commit 0f6b003

Browse files
committed
provide error and warning class names
1 parent 2d4f1d4 commit 0f6b003

File tree

2 files changed

+20
-11
lines changed

2 files changed

+20
-11
lines changed

R/epidatacall.R

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -50,20 +50,26 @@ create_epidata_call <- function(endpoint, params, meta = NULL,
5050
stopifnot(is.logical(only_supports_classic), length(only_supports_classic) == 1)
5151

5252
if (length(unique(meta)) != length(meta)) {
53-
cli::cli_abort(c(
54-
"List of expected epidata fields contains duplicate entries",
55-
"i" = "duplicates in meta can cause problems parsing fetched data",
56-
"Please fix in `endpoints.R`"
57-
))
53+
cli::cli_abort(
54+
c(
55+
"List of expected epidata fields contains duplicate entries",
56+
"i" = "duplicates in meta can cause problems parsing fetched data",
57+
"Please fix in `endpoints.R`"
58+
),
59+
class = "epidatr__duplicate_meta_entries"
60+
)
5861
}
5962

6063
meta_field_names <- map_chr(meta, ~ .x$name)
6164
if (length(meta_field_names) != length(unique(meta_field_names))) {
62-
cli::cli_abort(c(
63-
"List of expected epidata fields contains duplicate names",
64-
"i" = "duplicates in meta can cause problems parsing fetched data",
65-
"Please fix in `endpoints.R`"
66-
))
65+
cli::cli_abort(
66+
c(
67+
"List of expected epidata fields contains duplicate names",
68+
"i" = "duplicates in meta can cause problems parsing fetched data",
69+
"Please fix in `endpoints.R`"
70+
),
71+
class = "epidatr__duplicate_meta_names"
72+
)
6773
}
6874

6975
if (is.null(meta)) {

R/model.R

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,10 @@ parse_data_frame <- function(epidata_call, df, disable_date_parsing = FALSE) {
152152
if (
153153
length(setdiff(names(df), meta_field_names)) != 0
154154
) {
155-
cli::cli_warn("Not all return columns are specified as expected epidata fields")
155+
cli::cli_warn(
156+
"Not all return columns are specified as expected epidata fields",
157+
class = "epidatr__missing_meta_fields"
158+
)
156159
}
157160

158161
columns <- colnames(df)

0 commit comments

Comments
 (0)