[R-sig-DB] handling RS-DBI errors

Gabor Grothendieck ggrothend|eck @end|ng |rom gm@||@com
Tue Aug 10 12:09:04 CEST 2010


On Fri, Aug 6, 2010 at 7:29 PM, Homer V Strong <homer.strong using 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"




More information about the R-sig-DB mailing list