Skip to content

Commit

Permalink
Use tryCatch()
Browse files Browse the repository at this point in the history
  • Loading branch information
krlmlr committed May 1, 2022
1 parent faee421 commit c4e74a2
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions R/dbConnect_PqDriver.R
Original file line number Diff line number Diff line change
Expand Up @@ -109,13 +109,12 @@ dbConnect_PqDriver <- function(drv, dbname = NULL,
conn@timezone <- timezone
conn@timezone_out <- timezone_out

typnames <- try(dbGetQuery(conn, "SELECT oid, typname FROM pg_type", immediate = TRUE), silent = TRUE)

if (inherits(typnames, "try-error")) {
typnames <- data.frame(typname = character(), oid = character())
}

conn@typnames <- typnames
conn@typnames <- tryCatch(
dbGetQuery(conn, "SELECT oid, typname FROM pg_type", immediate = TRUE),
error = function(e) {
data.frame(typname = character(), oid = character())
}
)

on.exit(NULL)
conn
Expand Down

0 comments on commit c4e74a2

Please sign in to comment.