From afbb17d428f5f0b77ee17a796b7ff9fbcd893c2d Mon Sep 17 00:00:00 2001 From: Barbara Borges Ribeiro Date: Wed, 30 Mar 2016 07:29:58 +0100 Subject: [PATCH] errors are now sanitized in the app by default (must use options(shiny.sanitize.errors = FALSE) to override this behavior) --- R/shiny.R | 13 +++++++++++++ man/shiny-options.Rd | 6 ++++++ 2 files changed, 19 insertions(+) diff --git a/R/shiny.R b/R/shiny.R index 51d2f9544..054a7be73 100644 --- a/R/shiny.R +++ b/R/shiny.R @@ -96,6 +96,12 @@ NULL #' an arguably more intuitive arrangement for casual R users, as the name #' of a function appears next to the srcref where it is defined, rather than #' where it is currently being called from.} +#' \item{shiny.sanitize.errors}{If \code{TRUE} (the default), then normal +#' errors (i.e errors generated by \code{stop}) won't show up in the app; a +#' simple generic error message is printed instead (the error and strack trace +#' printed to the console remain unchanged). If you want this behavior in +#' general, but you DO want a particular error message to get displayed to the +#' user, please use \code{stopWithCondition} instead.} #' } #' @name shiny-options NULL @@ -592,6 +598,13 @@ ShinySession <- R6Class( if (isTRUE(getOption("show.error.messages"))) { printError(cond) } + if (getOption("shiny.sanitize.errors", TRUE)) { + cond$message <- paste("An error has occurred. Check your logs or contact", + "the app author for clarification.") + } else { + cond$message <- paste0("Error in output$", name, ": ", + conditionMessage(cond), "\n") + } invisible(structure(msg, class = "try-error", condition = cond)) }, finally = { diff --git a/man/shiny-options.Rd b/man/shiny-options.Rd index 70c2e3fab..9d65ed095 100644 --- a/man/shiny-options.Rd +++ b/man/shiny-options.Rd @@ -70,6 +70,12 @@ The default polling interval is 500 milliseconds. You can change this an arguably more intuitive arrangement for casual R users, as the name of a function appears next to the srcref where it is defined, rather than where it is currently being called from.} + \item{shiny.sanitize.errors}{If \code{TRUE} (the default), then normal + errors (i.e errors generated by \code{stop}) won't show up in the app; a + simple generic error message is printed instead (the error and strack trace + printed to the console remain unchanged). If you want this behavior in + general, but you DO want a particular error message to get displayed to the + user, please use \code{stopWithCondition} instead.} } }