Skip to content

Commit 477d463

Browse files
committed
updated customStop() documentation example to match Winston's pattern
1 parent a692b3c commit 477d463

File tree

2 files changed

+33
-25
lines changed

2 files changed

+33
-25
lines changed

R/utils.R

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -904,45 +904,49 @@ columnToRowData <- function(data) {
904904
#'
905905
#' @seealso \code{\link{shiny-options}}
906906
#'
907-
#' @export
908907
#' @examples
908+
#' ## Only run examples in interactive R sessions
909+
#' if (interactive()) {
910+
#'
909911
#' # uncomment the desired line to experiment with shiny.sanitize.errors
910912
#' # options(shiny.sanitize.errors = TRUE)
911913
#' # options(shiny.sanitize.errors = FALSE)
912914
#'
913-
#' # ui
914-
#' ui <- shinyUI(fluidPage(
915+
#' # Define UI
916+
#' ui <- fluidPage(
915917
#' textInput('number', 'Enter your favorite number from 1 to 10', '5'),
916918
#' textOutput('errorStop'),
917919
#' textOutput('errorCustomStop')
918-
#' ))
920+
#' )
919921
#'
920-
#' # server
921-
#' server <- shinyServer(function(input, output) {
922+
#' # Server logic
923+
#' server <- function(input, output) {
922924
#' output$errorStop <- renderText({
923925
#' number <- input$number
924926
#' if (number %in% 1:10) {
925927
#' return(paste('You chose', number, '!'))
926928
#' } else {
927-
#' return(stop(
929+
#' stop(
928930
#' paste(number, 'is not a number between 1 and 10')
929-
#' ))
931+
#' )
930932
#' }
931933
#' })
932934
#' output$errorCustomStop <- renderText({
933935
#' number <- input$number
934936
#' if (number %in% 1:10) {
935937
#' return(paste('You chose', number, '!'))
936938
#' } else {
937-
#' return(customStop(
939+
#' customStop(
938940
#' paste(number, 'is not a number between 1 and 10')
939-
#' ))
941+
#' )
940942
#' }
941943
#' })
942-
#' })
944+
#' }
943945
#'
944-
#' # run
945-
#' if (interactive()) shinyApp(ui = ui, server = server)
946+
#' # Complete app with UI and server components
947+
#' shinyApp(ui, server)
948+
#' }
949+
#' @export
946950
customStop <- function(error, errorClass = character(0)) {
947951
if (inherits(error, "error")) {
948952
class(error) <- c("shiny.custom.error", errorClass, class(error))

man/customStop.Rd

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

0 commit comments

Comments
 (0)