diff --git a/R/evaluate_smooth.R b/R/evaluate_smooth.R index eb0a90c7c..b100ffdc6 100644 --- a/R/evaluate_smooth.R +++ b/R/evaluate_smooth.R @@ -67,7 +67,7 @@ } smooth_ids <- which_smooth(object, smooth) # which smooths match 'smooth' if (identical(length(smooth_ids), 0L)) { - stop("Request smooth not found in the model <", smooth, ">", call. = FALSE) + stop("Requested smooth '", smooth, "' not found", call. = FALSE) } smooth_labels <- select_smooth(object, smooth) diff --git a/tests/testthat/test-evaluate-smooth-methods.R b/tests/testthat/test-evaluate-smooth-methods.R index ad4c07e66..c56563a77 100644 --- a/tests/testthat/test-evaluate-smooth-methods.R +++ b/tests/testthat/test-evaluate-smooth-methods.R @@ -26,6 +26,12 @@ test_that("evaluate_smooth throws a message with more than one term", { "Supplied more than 1 'smooth'; using only the first") }) +test_that("evaluate_smooth throws error if smooth not found", { + expect_error(evaluate_smooth(m1, smooth = "s(z)"), + "Requested smooth 's(z)' not found", + fixed = TRUE) +}) + test_that("evaluate_smooth works for a GAMM", { sm <- evaluate_smooth(m2, "s(x2)") expect_is(sm, "evaluated_1d_smooth")