Skip to content
Back to formatted view

Raw Message

Message-ID: <877go1xifi.wl%neal@walfield.org>
Date: 2012-12-29T10:26:57Z
From: Neal H. Walfield
Subject: parallel error message extraction (in mclapply)?
In-Reply-To: <CAPr7RtXxbWs68PY2YWO0f=WVFSvcU1ztgx1aVtpOk3kdmRS=tQ@mail.gmail.com>

Hi, Ivo,

At Fri, 28 Dec 2012 16:34:03 -0800,
ivo welch wrote:
> so, it isn't obvious to me how I get to the try-error object
> list, or how to find out what triggered the abort.  

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