Skip to content

Commit

Permalink
Fix error thrown while throwing error
Browse files Browse the repository at this point in the history
  • Loading branch information
richfitz committed Oct 15, 2024
1 parent 319c68d commit a1d279e
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
2 changes: 1 addition & 1 deletion R/filter-support.R
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
check_generator_for_filter <- function(generator, what, call = NULL) {
check_is_dust_system_generator(generator)
check_is_dust_system_generator(generator, substitute(generator))
if (!generator$properties$has_compare) {
cli::cli_abort(
paste("Can't create {what}; the '{generator$name}' system does",
Expand Down
8 changes: 8 additions & 0 deletions tests/testthat/test-filter.R
Original file line number Diff line number Diff line change
Expand Up @@ -649,3 +649,11 @@ test_that("can run continuous-time filter", {
"Can't use 'dust_filter_create()' with continuous-time models",
fixed = TRUE)
})


test_that("sensible error when given unevaluated generator", {
d <- data.frame(time = c(4, 8, 12, 16), incidence = c(1, 2, 3, 4))
expect_error(
dust_filter_create(sir, 0, d, 200),
"Expected 'generator' to be a 'dust_system_generator' object")
})

0 comments on commit a1d279e

Please sign in to comment.