(v1.2.0.9011) mo_domain(), improved error handling

This commit is contained in:
dr. M.S. (Matthijs) Berends committed 2020-06-22 11:18:40 +02:00
1 parent e88d7853f5
commit 93a158aebd
49 files changed
+523 -590

No files matched your search

+4 -9
View File
@@ -96,12 +96,8 @@ atc_online_property <- function(atc_code,
return(rep(NA, length(atc_code)))
}
if (length(property) != 1L) {
stop("`property` must be of length 1", call. = FALSE)
}
if (length(administration) != 1L) {
stop("`administration` must be of length 1", call. = FALSE)
}
stop_if(length(property) != 1L, "`property` must be of length 1")
stop_if(length(administration) != 1L, "`administration` must be of length 1")
# also allow unit as property
if (property %like% "unit") {
@@ -115,9 +111,8 @@ atc_online_property <- function(atc_code,
property <- tolower(property)
valid_properties <- tolower(valid_properties)
if (!property %in% valid_properties) {
stop("Invalid `property`, use one of ", paste(valid_properties.bak, collapse = ", "), ".")
}
stop_ifnot(property %in% valid_properties,
"Invalid `property`, use one of ", paste(valid_properties.bak, collapse = ", "))
if (property == "ddd") {
returnvalue <- rep(NA_real_, length(atc_code))