Capture the first graded()
signal or error thrown when evaluating the
expr
.
eval_gradethis(expr, on_error = NULL, on_graded = NULL)
expr | The expression or code block to evaluate |
---|---|
on_error | A |
on_graded | A |
# Passes with "message 1", short-circuiting evaluation eval_gradethis({ pass("message 1") pass("message 2") pass("message 3") })#> <gradethis_graded: [Correct] message 1>#> <gradethis_graded: [Incorrect] incorrect># Fails with message from expect_true() eval_gradethis({ testthat::expect_true(FALSE) pass("message 2") pass("message 3") })#> <gradethis_graded: [Incorrect] #> FALSE is not TRUE #> #> `actual`: FALSE #> `expected`: TRUE #> ># Fails immediately with message "boom" eval_gradethis({ stop("boom") pass("message 2") pass("message 3") })#> <gradethis_graded: [Incorrect] boom>