Hello DB SIG, I'm wondering how you hand RS-DBI driver errors in R. They don't seem to respect my attempts at try() or tryCatch() ing them. Any advice? I can provide specific examples if requested, but the scenario is simple: an ERROR occurs on the DB and try() and friends don't catch any exceptions. Thanks in advance! Homer
handling RS-DBI errors
2 messages · Homer V Strong, Gabor Grothendieck
3 days later
On Fri, Aug 6, 2010 at 7:29 PM, Homer V Strong <homer.strong at gmail.com> wrote:
Hello DB SIG, I'm wondering how you hand RS-DBI driver errors in R. They don't seem to respect my attempts at try() or tryCatch() ing them. Any advice? I can provide specific examples if requested, but the scenario is simple: an ERROR occurs on the DB and try() and friends don't catch any exceptions.
Which driver are you referring to? When I try it using RSQLite on Windows try does work to allow processing to continue. It still produces an error message (unless you use try(..., silent= TRUE)).
library(RSQLite)
con <- dbConnect(SQLite(), dbname = ":memory:")
f <- function() {
+ out <- try(dbGetQuery(con, "select * from nosuchexists"), silent = TRUE) + class(out) + }
f()
[1] "try-error"
R.version.string
[1] "R version 2.11.1 Patched (2010-05-31 r52167)"
win.version()
[1] "Windows Vista (build 6002) Service Pack 2"