EVOLUTION-MANAGER
Edit File: safeError.html
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><title>R: Declare an error safe for the user to see</title> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <link rel="stylesheet" type="text/css" href="R.css" /> </head><body> <table width="100%" summary="page for safeError {shiny}"><tr><td>safeError {shiny}</td><td style="text-align: right;">R Documentation</td></tr></table> <h2>Declare an error safe for the user to see</h2> <h3>Description</h3> <p>This should be used when you want to let the user see an error message even if the default is to sanitize all errors. If you have an error <code>e</code> and call <code>stop(safeError(e))</code>, then Shiny will ignore the value of <code>getOption("shiny.sanitize.errors")</code> and always display the error in the app itself. </p> <h3>Usage</h3> <pre> safeError(error) </pre> <h3>Arguments</h3> <table summary="R argblock"> <tr valign="top"><td><code>error</code></td> <td> <p>Either an "error" object or a "character" object (string). In the latter case, the string will become the message of the error returned by <code>safeError</code>.</p> </td></tr> </table> <h3>Details</h3> <p>An error generated by <code>safeError</code> has priority over all other Shiny errors. This can be dangerous. For example, if you have set <code>options(shiny.sanitize.errors = TRUE)</code>, then by default all error messages are omitted in the app, and replaced by a generic error message. However, this does not apply to <code>safeError</code>: whatever you pass through <code>error</code> will be displayed to the user. So, this should only be used when you are sure that your error message does not contain any sensitive information. In those situations, <code>safeError</code> can make your users' lives much easier by giving them a hint as to where the error occurred. </p> <h3>Value</h3> <p>An "error" object </p> <h3>See Also</h3> <p><code><a href="shinyOptions.html">shiny-options()</a></code> </p> <h3>Examples</h3> <pre> ## Only run examples in interactive R sessions if (interactive()) { # uncomment the desired line to experiment with shiny.sanitize.errors # options(shiny.sanitize.errors = TRUE) # options(shiny.sanitize.errors = FALSE) # Define UI ui <- fluidPage( textInput('number', 'Enter your favorite number from 1 to 10', '5'), textOutput('normalError'), textOutput('safeError') ) # Server logic server <- function(input, output) { output$normalError <- renderText({ number <- input$number if (number %in% 1:10) { return(paste('You chose', number, '!')) } else { stop( paste(number, 'is not a number between 1 and 10') ) } }) output$safeError <- renderText({ number <- input$number if (number %in% 1:10) { return(paste('You chose', number, '!')) } else { stop(safeError( paste(number, 'is not a number between 1 and 10') )) } }) } # Complete app with UI and server components shinyApp(ui, server) } </pre> <hr /><div style="text-align: center;">[Package <em>shiny</em> version 1.5.0 <a href="00Index.html">Index</a>]</div> </body></html>