Skip to content
Prev 314331 / 398513 Next

parallel error message extraction (in mclapply)?

Hi, Ivo,

At Fri, 28 Dec 2012 16:34:03 -0800,
ivo welch wrote:
A try object is an object that captures the execution context at the
time of an error.  Consider the following code:

  > library(multicore)
  > result = mclapply(1:10, function (i) { if (i == 4) foo() else i })
  Warning message:
  In mclapply(1:10, function(i) { :
    scheduled core 4 encountered error in user code, all values of the job will be affected

To investigate the error, we can use the try object that has been
saved in position 4:

  > print(result[[4]])
  [1] "Error in FUN(4L[[1L]], ...) : could not find function \"foo\"\n"
  attr(,"class")
  [1] "try-error"
  attr(,"condition")
  <simpleError in FUN(4L[[1L]], ...): could not find function "foo"
  > traceback(result[[4]])
  1: Error in FUN(4L[[1L]], ...) : could not find function "foo"

Neal