Skip to content

Commit 0bd51ed

Browse files
topepohfrick
andauthored
Update R/aaa_models.R
Co-authored-by: Hannah Frick <[email protected]>
1 parent 523cd1b commit 0bd51ed

File tree

1 file changed

+16
-11
lines changed

1 file changed

+16
-11
lines changed

R/aaa_models.R

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -135,19 +135,24 @@ check_mode_val <- function(mode) {
135135
}
136136

137137

138-
stop_incompatible_mode <- function(spec_modes, eng) {
139-
if (is.null(eng)) {
140-
msg <- glue::glue(
141-
"Available modes are: ",
142-
glue::glue_collapse(glue::glue("'{spec_modes}'"), sep = ", ")
143-
)
144-
} else {
145-
msg <- glue::glue(
146-
"Available modes for engine {eng} are: ",
147-
glue::glue_collapse(glue::glue("'{spec_modes}'"), sep = ", ")
148-
)
138+
stop_incompatible_mode <- function(spec_modes, eng = NULL, cls = NULL) {
139+
if (is.null(eng) & is.null(cls)) {
140+
msg <- "Available modes are: "
141+
}
142+
if (!is.null(eng) & is.null(cls)) {
143+
msg <- glue::glue("Available modes for engine {eng} are: ")
144+
}
145+
if (is.null(eng) & !is.null(cls)) {
146+
msg <- glue::glue("Available modes for model type {cls} are: ")
147+
}
148+
if (!is.null(eng) & !is.null(cls)) {
149+
msg <- glue::glue("Available modes for model type {cls} with engine {eng} are: ")
149150
}
150151

152+
msg <- glue::glue(
153+
msg,
154+
glue::glue_collapse(glue::glue("'{spec_modes}'"), sep = ", ")
155+
)
151156
rlang::abort(msg)
152157
}
153158

0 commit comments

Comments
 (0)