@@ -311,7 +311,7 @@ static ErrorProcessingResult processErrors(
311
311
boolean isExecutionException = isExecutionException (cause );
312
312
if (keepGoing ) {
313
313
aggregatingResultBuilder .aggregateSingleResult (individualErrorProcessingResult );
314
- printWarningMessage (isExecutionException , label , eventHandler );
314
+ logOrPrintWarnings (isExecutionException , label , eventHandler , cause );
315
315
} else {
316
316
noKeepGoingAnalysisExceptionAspect =
317
317
throwOrReturnAspectAnalysisException (
@@ -569,17 +569,29 @@ private static DetailedExitCode sendBugReportAndCreateUnknownExecutionDetailedEx
569
569
return createDetailedExecutionExitCode (message , UNKNOWN_EXECUTION );
570
570
}
571
571
572
- private static void printWarningMessage (
572
+ private static void logOrPrintWarnings (
573
573
boolean isExecutionException ,
574
574
@ Nullable Label topLevelLabel ,
575
- ExtendedEventHandler eventHandler ) {
576
- String warningMsg =
577
- isExecutionException
578
- ? String .format ("errors encountered while building target '%s'" , topLevelLabel )
579
- : String .format (
575
+ ExtendedEventHandler eventHandler ,
576
+ Exception cause ) {
577
+ // For execution exceptions, we don't print any extra warning.
578
+ if (isExecutionException ) {
579
+ if (isExecutionCauseWorthLogging (cause )) {
580
+ logger .atWarning ().withCause (cause ).log (
581
+ "Non-action-execution/input-error exception while building target %s" , topLevelLabel );
582
+ }
583
+ return ;
584
+ }
585
+ eventHandler .handle (
586
+ Event .warn (
587
+ String .format (
580
588
"errors encountered while analyzing target '%s': it will not be built" ,
581
- topLevelLabel );
582
- eventHandler .handle (Event .warn (warningMsg ));
589
+ topLevelLabel )));
590
+ }
591
+
592
+ private static boolean isExecutionCauseWorthLogging (Throwable cause ) {
593
+ return !(cause instanceof ActionExecutionException )
594
+ && !(cause instanceof InputFileErrorException );
583
595
}
584
596
585
597
private static boolean isValidErrorKeyType (Object errorKey ) {
@@ -842,8 +854,7 @@ private static DetailedExitCode getDetailedExitCodeKeepGoing(EvaluationResult<?>
842
854
detailedExitCode =
843
855
DetailedExitCodeComparator .chooseMoreImportantWithFirstIfTie (
844
856
detailedExitCode , ((DetailedException ) cause ).getDetailedExitCode ());
845
- if (!(cause instanceof ActionExecutionException )
846
- && !(cause instanceof InputFileErrorException )) {
857
+ if (isExecutionCauseWorthLogging (cause )) {
847
858
logger .atWarning ().withCause (cause ).log (
848
859
"Non-action-execution/input-error exception for %s" , error );
849
860
}
0 commit comments