Closed krlmlr closed 7 years ago
Well, I find it more convenient to see the error message in the console than in the output document. The latter can be long, and it may not be easy to realize that an error occurred if R does not shout out loud enough.
But do you actually see the error message, e.g., when rendering using rmarkdown::render() from RStudio? I didn't the last few times I tried, it was very frustrating. Failing to measure a string isn't fatal in most cases, too -- even if the LaTeX syntax is invalid, chances are that pdflatex will be able to recover.
Okay, if the error message is not displayed at all, I think we definitely should fix it. But it seems I can see the error message in the console. A minimal example:
---
title: "Untitled"
author: "Yihui Xie"
output: pdf_document
---
```{r pressure, dev='tikz'}
plot(pressure, xlab='\\invalid{} command')
![screen shot 2016-03-07 at 4 42 08 pm](https://cloud.githubusercontent.com/assets/163582/13585827/91e4a12a-e483-11e5-9010-6ca07faca685.png)
Oh, right... The error message is shown, but not the log file contents or the input file, which are printed just before using message()
. These are very helpful for debugging. It doesn't matter if I use message = TRUE
or message = FALSE
in the chunk.
If we add this to the stop() message, we start hitting length limits very soon (1000 chars or so). A temp file would be an option, but these are removed when R exits.
The more general problem is that messages from a failing chunk seem to appear nowhere. Should this be solved elsewhere?
Can you parse the real error messages from the log file instead of dumping the full log? Here is my approximate solution: https://github.com/rstudio/rmarkdown/blob/c97053384dae1c0b254f73a354801bbb73176660/R/util.R#L343-L362 Basically I only extract the lines that start with !
.
Obsolete with #142.
The error message is not very helpful, I usually don't see log output on the console. With a warning, the error message is at least shown in the document.
@yihui: Should we use an option to control this behavior? What should be the default?