[Rd] Changing HTML Error code message

Gabriel Guzman g@br|e|@guzm@n@25u @end|ng |rom gm@||@com
Mon Oct 7 06:43:02 CEST 2019


Hello,

I'm relatively new to using R and shiny. Currently, I'm getting the Error:
Conflict (HTTP  409) when trying to access an html file from dropbox and
this is fine, I know the reason. What I do have a problem with is trying to
find a way to change Error code message. Instead of simply "Error: Conflict
(HTTP  409)", I would a message a client might be able to understand. I've
tried a couple forms of validation and try-catches. I'm including the code
and simple html files to recreate the problem. Any and all suggestions are
welcome. Thank you in advance for your help.



library(shiny)
library(rdrop2)
library(httr)

ui <- # Define UI for dataset viewer application

  shinyUI(pageWithSidebar(

    headerPanel("Test DropBox html Docs to Shiny"),

    sidebarPanel(

      selectInput("Cat", "Choose a Category:",

                  choices = c("A", "B", "C")),

      selectInput("Year", "Choose a Year:",

                  choices = c("2012", "2011")),

      downloadButton("downFile", "Download File"),

      width = 2),


    mainPanel(

      tabsetPanel(type = "tabs",

                  tabPanel("Html Pages", htmlOutput("viewReport"))), width
= 10)
    )
  )

#IMPORTANT: The two lines below needs to be run just one time unless the
token is deleted

# Create Token

# token <- drop_auth()

# Save token

# saveRDS(token, "droptoken.rds")

token <- readRDS("droptoken.rds")


server <- shinyServer(function(input, output) {


# ---------------------------------------------------
  filePutReport <- reactive(

    paste(input$Cat, "_", input$Year, "_Doc.html", sep = "")

  )

  filePutReport2 <- reactive({
    # Search if the file exists in DropBox


    drop_download(path = paste("shiny_docs/shinydbtest/", filePutReport(),
sep = ""),
                  overwrite = TRUE, local_path = "./www",
             dtoken = token)

      filePutReport()

  })

  # Show Html Pages

  output$viewReport <- renderUI({

    tags$iframe(seamless = "seamless", width = "1400", height = "1000",

                src = filePutReport2()
                )
  })


  ###
  output$downFile <- downloadHandler(
    # generate bins based on input$bins from ui.R
    filename = function() {

      paste0(filePutReport() )
    },

    content = function(file){

      file.copy(from = paste0("./www/", filePutReport2() ), to = file,
overwrite = TRUE)
    }

  )

})

shinyApp(ui = ui, server = server)


More information about the R-devel mailing list