title: Change reactive value in a tryCatch in shiny
body: <p><strong>Background</strong></p>
  
  <p>In my app I want to allow the user to download a snapshot of an SQL database. As there may be some errors with the SQL connection, I thought of using a <code>tryCatch</code> construct. If there is an error, I want to display a meaningful error message to the user. For that, I created a <code>reactiveVal</code> whose value I set in the error handler bit. I see that the value is changed in the error handler, but the <code>renderPrint</code> function does not fire. Any idea of what I have to change?</p>
  
  <p><strong>Code</strong></p>
  
  <pre><code>library(shiny)
  
  ui &lt;- fluidPage(downloadButton("dat"), verbatimTextOutput("debug"))
  
  server &lt;- function(input, output) {
     errMsg &lt;- reactiveVal()
     output$dat &lt;- downloadHandler(filename = "test.xlsx",
                                   content = function(nF) {
                                      tryCatch({
                                         write.csv(mtcars, nF)
                                         stop("simulate SQL error")
                                      }, error = function(err) {
                                         print("Error Handler")
                                         errMsg("Error")
                                      })
  
                                   })
     output$debug &lt;- renderPrint(errMsg())
  
  }
  
  shinyApp(ui, server)
  </code></pre>