Skip to content

Commit

Permalink
Throw an informative error if an exercise chunk is NULL, closes #410
Browse files Browse the repository at this point in the history
  • Loading branch information
cpsievert committed Jul 29, 2020
1 parent 7164dde commit 156c44e
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions R/knitr-hooks.R
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,15 @@ install_knitr_hooks <- function() {
call. = FALSE)
}

# validate that the exercise chunk is 'defined'
if (exercise_chunk && is.null(get_knitr_chunk(options$label))) {
stop(
"The exercise chunk '", options$label, "' doesn't have anything inside of it. ",
"Try adding empty line(s) inside the code chunk.",
call. = FALSE
)
}

# if this is an exercise chunk then set various options
if (exercise_chunk) {

Expand Down

0 comments on commit 156c44e

Please sign in to comment.