I've tried multiple examples I found on here and elsewhere but it always fails to do what I want.
My R script is simply a configuration validation script, it checks to make sure the user has their environment setup correctly. So I want to try 5 different steps and report on the status of each so that the user can go and fix everything all at once. For example, my first step tests the connection to the database, if that fails I want to print a message and continue on to step 2. But it always halts execution when it errors out and so I only get to the failure and then no more.
I am running the script from command line using RScript.exe on W64. Here's my basic tryCatch, I tried it with the error function and without, it makes no difference, it always breaks on the error.
tryCatch(
expr = {
res<- dbGetQuery(con, sql)
print("SQL query results:")
print(res)
}
)