Skip to content

Commit 5484259

Browse files
committed
better catch non-supoported models in check_model()
1 parent 1050490 commit 5484259

File tree

1 file changed

+17
-9
lines changed

1 file changed

+17
-9
lines changed

R/check_model.R

+17-9
Original file line numberDiff line numberDiff line change
@@ -108,16 +108,24 @@ check_model.default <- function(x,
108108

109109
minfo <- insight::model_info(x, verbose = FALSE)
110110

111-
if (minfo$is_bayesian) {
112-
ca <- suppressWarnings(.check_assumptions_stan(x))
113-
} else if (minfo$is_linear) {
114-
ca <- suppressWarnings(.check_assumptions_linear(x, minfo, verbose))
115-
} else {
116-
ca <- suppressWarnings(.check_assumptions_glm(x, minfo, verbose))
111+
ca <- tryCatch(
112+
{
113+
if (minfo$is_bayesian) {
114+
suppressWarnings(.check_assumptions_stan(x))
115+
} else if (minfo$is_linear) {
116+
suppressWarnings(.check_assumptions_linear(x, minfo, verbose))
117+
} else {
118+
suppressWarnings(.check_assumptions_glm(x, minfo, verbose))
119+
}
120+
},
121+
error = function(e) {
122+
NULL
123+
}
124+
)
125+
126+
if (is.null(ca)) {
127+
stop(paste0("`check_model()` not implemented for models of class '", class(x)[1], "' yet."), call. = FALSE)
117128
}
118-
# else {
119-
# stop(paste0("`check_assumptions()` not implemented for models of class '", class(x)[1], "' yet."), call. = FALSE)
120-
# }
121129

122130
attr(ca, "panel") <- panel
123131
attr(ca, "dot_size") <- dot_size

0 commit comments

Comments
 (0)