diff --git a/modules/nextflow/src/main/groovy/nextflow/executor/local/NativeTaskHandler.groovy b/modules/nextflow/src/main/groovy/nextflow/executor/local/NativeTaskHandler.groovy index bb7b7804d8..910a4248e0 100644 --- a/modules/nextflow/src/main/groovy/nextflow/executor/local/NativeTaskHandler.groovy +++ b/modules/nextflow/src/main/groovy/nextflow/executor/local/NativeTaskHandler.groovy @@ -17,6 +17,7 @@ package nextflow.executor.local +import java.lang.reflect.InvocationTargetException import java.util.concurrent.Callable import java.util.concurrent.Future @@ -91,11 +92,15 @@ class NativeTaskHandler extends TaskHandler { boolean checkIfCompleted() { if( isRunning() && result.isDone() ) { status = TaskStatus.COMPLETED - if( result.get() instanceof Throwable ) { - task.error = (Throwable)result.get() + final ret = result.get() + if( ret instanceof InvocationTargetException ) { + task.error = ret.cause + } + else if( ret instanceof Throwable ) { + task.error = (Throwable)ret } else { - task.stdout = result.get() + task.stdout = ret } return true }