@@ -383,6 +383,7 @@ result.BatchtoolsFuture <- function(future, cleanup = TRUE, ...) {
383383
384384# ' @importFrom future run getExpression
385385# ' @importFrom batchtools batchExport batchMap saveRegistry setJobNames submitJobs
386+ # ' @importFrom utils capture.output str
386387# ' @export
387388run.BatchtoolsFuture <- function (future , ... ) {
388389 if (future $ state != " created" ) {
@@ -517,8 +518,19 @@ run.BatchtoolsFuture <- function(future, ...) {
517518
518519 # # WORKAROUND: batchtools::submitJobs() updates the RNG state,
519520 # # which we must make sure to undo.
520- with_stealth_rng({
521- submitJobs(reg = reg , ids = jobid , resources = resources )
521+ tryCatch({
522+ with_stealth_rng({
523+ submitJobs(reg = reg , ids = jobid , resources = resources )
524+ })
525+ }, error = function (ex ) {
526+ msg <- conditionMessage(ex )
527+ label <- future $ label
528+ if (is.null(label )) label <- " <none>"
529+ msg <- sprintf(" Failed to submit %s (%s). The reason was: %s" , class(future )[1 ], label , msg )
530+ info <- capture.output(str(resources ))
531+ info <- paste(info , collapse = " \n " )
532+ msg <- sprintf(" %s\n TROUBLESHOOTING INFORMATION:\n batchtools::submitJobs() was called with the following 'resources' argument:\n %s\n " , msg , info )
533+ stop(BatchtoolsFutureError(msg , future = future ))
522534 })
523535
524536 mdebugf(" Launched future #%d" , jobid $ job.id )
0 commit comments