Try catch function in shiny

Hi, I have an app that copies files and moves them to a preset directory. I am trying to incorporate trycatch into my app. Where if the user adds a path that doesn't exist, it lets them know, and lets them continue/try again. Here is my server code. How could I incorporate this into my code.
server <- function(input , output){
destDir <- 'H:/Shiny/FileTransfer/TestLocation'

output$result <- renderPrint({
inFile <- input$file1
if (is.null(inFile)) {
cat("NO FILE\n")
return(FALSE)
}
cat("Reading file:", inFile$name, "\n")
cat("size:", inFile$size, " Bytes, type:", inFile$type, "\n")
if (dir.exists(destDir)){
cat("Copying file to:", destDir,"\n")
result <- file.copy( inFile$datapath,
file.path(destDir, inFile$name) )
} else {
result <- FALSE
}
result
})
}
Thank you in advance,
Jeffrey

This topic was automatically closed 54 days after the last reply. New replies are no longer allowed.