class.output does not apply to errors (see here ).
Following this answer , I suggest you take advantage of the error:
```{r error-hook, echo=FALSE} knitr::knit_hooks$set(error = function(x, options) { paste0( "```{", ifelse(is.null(options$class.error), "", paste0(" .", gsub(" ", " .", options$class.error)) ), "}\n", x, "\n```" ) }) ```
Now you can use the "new" class.error option in your piece.
```{r, error = TRUE, class.error="red"} rnorm(-10) ```
Feel free to open a feature request here .
romles
source share