[R] gracefully handing a library load error

From: Will Holcomb <wholcomb_at_gmail.com>
Date: Wed, 12 Mar 2008 00:00:18 -0400

I have an R program I am attempting to use to generate some SVGs. I've been using the cairoDevice library. When running a session not connected to an X session (like if I'm sshed in), attempting "library(cairoDevice)" causes:


  1. .C("R_gtk_setEventHandler", PACKAGE = "cairoDevice")
  2. firstlib(which.lib.loc, package)
  3. doTryCatch(return(expr), name, parentenv, handler)
  4. tryCatchOne(expr, names, parentenv, handlers[[1]])
  5. tryCatchList(expr, classes, parentenv, handlers)
  6. tryCatch(expr, error = function(e) { call <- conditionCall(e) if (!is.null(call)) { if (identical(call[[1]], quote(doTryCatch))) call <- sys.call(-4) dcall <- deparse(call)[1] prefix <- paste("Error in", dcall, ": ") LONGCALL <- 30 if (nchar(dcall) > LONGCALL) prefix <- paste(prefix, "\n\t", sep = "") } else prefix <- "Error : " msg <- paste(prefix, conditionMessage(e), "\n", sep = "") .Internal(seterrmessage(msg[1])) if (!silent && identical(getOption(" show.error.messages"), TRUE)) { cat(msg, file = stderr()) .Internal(printDeferredWarnings()) } invisible(structure(msg, class = "try-error"))})
  7. try(firstlib(which.lib.loc, package))
  8. library(cairoDevice) aborting ... Segmentation fault (core dumped)

I'm fine with the idea that Cairo somehow needs the X server to do its business. I would like to not have the program segfault however and instead just skip the SVG if it can't load the library. I've been hunting to see how to do error handling in R and I'm not really finding a good resource. Can anyone suggest one?


        [[alternative HTML version deleted]]

R-help_at_r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. Received on Wed 12 Mar 2008 - 04:03:16 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Wed 12 Mar 2008 - 08:30:20 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive