title: Can't resolve error in .Rmd file <Anonymous> ... withCallingHandlers -> withVisible -> eval -> eval ->
body: <p>I'm trying to write a document that discusses using errors to communicate problems with the arguments to the user.  Unfortunately, I can't seem to get the .Rmd file to knit.  A short example:</p>
  
  <pre><code>Intro text
  
  ```{r}
  some_function &lt;- function(x, y)
  {
    if (x &lt; 0) stop("x must be greater than 0")
    x + y
  }
  
  some_function(3, 2)
  ```
  
  ```{r}
  some_function(-3, 2)
  ```
  </code></pre>
  
  <p>When I try to knit this to any format, I get the error</p>
  
  <pre><code>Quitting from lines 14-15 (test.Rmd) 
  Error in some_function(-3, 2) : x &lt; 0
  Calls: &lt;Anonymous&gt; ... withCallingHandlers -&gt; withVisible -&gt; eval -&gt; eval -&gt; some_function
  
  Execution halted
  </code></pre>
  
  <p>Everything I've read so far points to this being a problem with either a) not loading a package, or b) an incorrectly set path in the Rmd file.</p>
  
  <p>Since I'm only using base functions here and am not referencing any files (that I'm aware of, anyway), I don't think either of those are my problem (but I'll be happy to be wrong).</p>
  
  <p>Any tips on what I need to do to get the document to knit?</p>
  
  <p><strong>Solution</strong></p>
  
  <p>Add the following to the top of the .Rmd</p>
  
  <pre><code>```{r, echo=FALSE}
  knitr::opts_chunk$set(error = TRUE)
  ```
  </code></pre>
  
  <p>Short explanation, RMarkdown v1 used <code>error = TRUE</code> by default, but RMarkdown v2 uses <code>error = FALSE</code>.  See the link in Josh's comment below. </p>