Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

More informative messages when fail_if(cond = ) is invalid #341

Merged
merged 6 commits into from
Apr 4, 2023

Conversation

rossellhayes
Copy link
Contributor

pass_if() and fail_if() now produce more informative error messages if their cond argument is invalid.

grade_this({
  fail_if(!all.equal(.result, .solution), "Oops!")
})(mock_this_exercise("1", "2"))
#> Warning in assert_gradethis_condition_does_not_error(cond, from): The `cond` argument to `fail_if()` produced an error:
#>   Error in !all.equal(.result, .solution) : invalid argument type
#> <gradethis_graded: [Neutral]
#>   A problem occurred with the grading code for this exercise.
#> >

grade_this({
  pass_if(all.equal(.result, .solution), "Nice!")
})(mock_this_exercise("1", "2"))
#> Warning in assert_gradethis_condition_is_logical(cond, from): The `cond`
#> argument to `pass_if()` must be coercible to logical, not an object of class
#> <character>.
#> <gradethis_graded: [Neutral]
#>   A problem occurred with the grading code for this exercise.
#> >

grade_this({
  pass_if(NA, "Nice!")
})(mock_this_exercise("1", "2"))
#> Warning in assert_gradethis_condition_is_not_na(cond, from): The `cond`
#> argument to `pass_if()` must not be `NA`.
#> <gradethis_graded: [Neutral]
#>   A problem occurred with the grading code for this exercise.
#> >

Created on 2023-04-04 with reprex v2.0.2

Closes #340.

@rossellhayes rossellhayes merged commit 02f23cd into main Apr 4, 2023
@rossellhayes rossellhayes deleted the feat/better-fail_if-error branch April 4, 2023 22:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

fail_if() gives a cryptic message if cond errors
1 participant