Get a backtrace from an error in `mclapply`

103 views Asked by At

A toy example:

> f = \(x) if (x == 4) stop("Oh no!") else x
> x = parallel::mclapply(1:10, f)                                                   
Warning in parallel::mclapply(1:10, f) :
  scheduled core 2 encountered error in user code, all values of the job will be aff
ected

I can see the message I put in stop, "Oh no!", but not the call stack:

> x[[2]]
[1] "Error in FUN(X[[i]], ...) : Oh no!\n"
attr(,"class")
[1] "try-error"
attr(,"condition")
<simpleError in FUN(X[[i]], ...): Oh no!>
> traceback()
No traceback available

Is there any way to see the call stack from where the error arose? I'm on R 4.2.1.

0

There are 0 answers