When dbConnect fails, for reasons like when the Postgres connection limit is reached, the error returned does not include the error message, only:
Error in postgresqlNewConnection(drv, ...) :
RS-DBI driver: (could not connect ...)
Calls: dbConnect -> dbConnect -> postgresqlNewConnection -> .Call
Execution halted
Wrapping the connection in a tryCatch does not provide any additional message detail, and dbGetException() requires a connection object, which of course does not exist.
Is this a limitation in the currenr RPostgreSQL error handler?
con <- tryCatch(
{ dbConnect(drv, host = "***", dbname = "***", user = "***") },
error=function(cond) {
message("DB conn failed")
message(cond)
return(NA)
}
)