Skip to content

Commit 99a7f37

Browse files
authored
Fix secondary exceptions from console (#5518)
Signed-off-by: Paolo Di Tommaso <[email protected]>
1 parent fa0e8e0 commit 99a7f37

File tree

2 files changed

+15
-5
lines changed

2 files changed

+15
-5
lines changed

modules/nextflow/src/main/groovy/nextflow/Session.groovy

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ import nextflow.util.Barrier
7171
import nextflow.util.ConfigHelper
7272
import nextflow.util.Duration
7373
import nextflow.util.HistoryFile
74+
import nextflow.util.LoggerHelper
7475
import nextflow.util.NameGenerator
7576
import nextflow.util.SysHelper
7677
import nextflow.util.ThreadPoolManager
@@ -787,10 +788,11 @@ class Session implements ISession {
787788
*/
788789
void abort(Throwable cause = null) {
789790
if( aborted ) return
790-
if( !(cause instanceof ScriptCompilationException) )
791+
if( cause !instanceof ScriptCompilationException )
791792
log.debug "Session aborted -- Cause: ${cause?.message ?: cause ?: '-'}"
792793
aborted = true
793794
error = cause
795+
LoggerHelper.aborted = true
794796
try {
795797
// log the dataflow network status
796798
def status = dumpNetworkStatus()

modules/nextflow/src/main/groovy/nextflow/util/LoggerHelper.groovy

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,6 @@
1616

1717
package nextflow.util
1818

19-
import ch.qos.logback.core.encoder.Encoder
20-
import ch.qos.logback.core.spi.FilterAttachable
21-
import ch.qos.logback.core.spi.LifeCycle
22-
2319
import static nextflow.Const.*
2420

2521
import java.lang.reflect.Field
@@ -28,6 +24,7 @@ import java.nio.file.FileAlreadyExistsException
2824
import java.nio.file.NoSuchFileException
2925
import java.nio.file.Path
3026
import java.util.concurrent.atomic.AtomicBoolean
27+
import java.util.concurrent.atomic.AtomicInteger
3128
import java.util.regex.Pattern
3229

3330
import ch.qos.logback.classic.Level
@@ -42,13 +39,16 @@ import ch.qos.logback.core.ConsoleAppender
4239
import ch.qos.logback.core.CoreConstants
4340
import ch.qos.logback.core.FileAppender
4441
import ch.qos.logback.core.LayoutBase
42+
import ch.qos.logback.core.encoder.Encoder
4543
import ch.qos.logback.core.encoder.LayoutWrappingEncoder
4644
import ch.qos.logback.core.filter.Filter
4745
import ch.qos.logback.core.joran.spi.NoAutoStart
4846
import ch.qos.logback.core.rolling.FixedWindowRollingPolicy
4947
import ch.qos.logback.core.rolling.RollingFileAppender
5048
import ch.qos.logback.core.rolling.TriggeringPolicyBase
49+
import ch.qos.logback.core.spi.FilterAttachable
5150
import ch.qos.logback.core.spi.FilterReply
51+
import ch.qos.logback.core.spi.LifeCycle
5252
import ch.qos.logback.core.util.FileSize
5353
import groovy.transform.CompileStatic
5454
import groovy.transform.PackageScope
@@ -85,6 +85,10 @@ import org.slf4j.MarkerFactory
8585
@CompileStatic
8686
class LoggerHelper {
8787

88+
static volatile boolean aborted
89+
90+
static final AtomicInteger errCount = new AtomicInteger()
91+
8892
static private Logger log = LoggerFactory.getLogger(LoggerHelper)
8993

9094
static public Marker STICKY = MarkerFactory.getMarker('sticky')
@@ -419,6 +423,10 @@ class LoggerHelper {
419423
return FilterReply.NEUTRAL;
420424
}
421425

426+
// print to console only the very first error log and ignore the others
427+
if( aborted && event.level==Level.ERROR && errCount.getAndIncrement()>0 )
428+
return FilterReply.DENY;
429+
422430
def logger = event.getLoggerName()
423431
def level = event.getLevel()
424432
for( int i=0; i<len; i++ ) {

0 commit comments

Comments
 (0)