Skip to content

Commit afbb17d

Browse files
committed
errors are now sanitized in the app by default (must use options(shiny.sanitize.errors = FALSE) to override this behavior)
1 parent c7eb7ba commit afbb17d

File tree

2 files changed

+19
-0
lines changed

2 files changed

+19
-0
lines changed

R/shiny.R

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,12 @@ NULL
9696
#' an arguably more intuitive arrangement for casual R users, as the name
9797
#' of a function appears next to the srcref where it is defined, rather than
9898
#' where it is currently being called from.}
99+
#' \item{shiny.sanitize.errors}{If \code{TRUE} (the default), then normal
100+
#' errors (i.e errors generated by \code{stop}) won't show up in the app; a
101+
#' simple generic error message is printed instead (the error and strack trace
102+
#' printed to the console remain unchanged). If you want this behavior in
103+
#' general, but you DO want a particular error message to get displayed to the
104+
#' user, please use \code{stopWithCondition} instead.}
99105
#' }
100106
#' @name shiny-options
101107
NULL
@@ -592,6 +598,13 @@ ShinySession <- R6Class(
592598
if (isTRUE(getOption("show.error.messages"))) {
593599
printError(cond)
594600
}
601+
if (getOption("shiny.sanitize.errors", TRUE)) {
602+
cond$message <- paste("An error has occurred. Check your logs or contact",
603+
"the app author for clarification.")
604+
} else {
605+
cond$message <- paste0("Error in output$", name, ": ",
606+
conditionMessage(cond), "\n")
607+
}
595608
invisible(structure(msg, class = "try-error", condition = cond))
596609
},
597610
finally = {

man/shiny-options.Rd

Lines changed: 6 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)