@@ -272,11 +272,7 @@ public SpawnResult exec(Spawn spawn, SpawnExecutionContext context)
272
272
// It's already late at this stage, but we should at least report once.
273
273
reporter .reportExecutingIfNot ();
274
274
275
- FileOutErr outErr = context .getFileOutErr ();
276
- String message = result .getMessage ();
277
- if (!result .success () && !message .isEmpty ()) {
278
- outErr .printErr (message + "\n " );
279
- }
275
+ maybePrintExecutionMessages (context , result .getMessage (), result .success ());
280
276
281
277
profileAccounting (result .getExecutionMetadata ());
282
278
spawnMetricsAccounting (spawnMetrics , result .getExecutionMetadata ());
@@ -444,6 +440,17 @@ public boolean handlesCaching() {
444
440
return true ;
445
441
}
446
442
443
+ private void maybePrintExecutionMessages (
444
+ SpawnExecutionContext context , String message , boolean success ) {
445
+ FileOutErr outErr = context .getFileOutErr ();
446
+ boolean printMessage =
447
+ remoteOptions .remotePrintExecutionMessages .shouldPrintMessages (success )
448
+ && !message .isEmpty ();
449
+ if (printMessage ) {
450
+ outErr .printErr (message + "\n " );
451
+ }
452
+ }
453
+
447
454
private void maybeWriteParamFilesLocally (Spawn spawn ) throws IOException {
448
455
if (!executionOptions .shouldMaterializeParamFiles ()) {
449
456
return ;
@@ -500,10 +507,11 @@ private SpawnResult execLocallyAndUploadOrFail(
500
507
if (remoteOptions .remoteLocalFallback && !RemoteRetrierUtils .causedByExecTimeout (cause )) {
501
508
return execLocallyAndUpload (action , spawn , context , uploadLocalResults );
502
509
}
503
- return handleError (action , cause );
510
+ return handleError (action , cause , context );
504
511
}
505
512
506
- private SpawnResult handleError (RemoteAction action , IOException exception )
513
+ private SpawnResult handleError (
514
+ RemoteAction action , IOException exception , SpawnExecutionContext context )
507
515
throws ExecException , InterruptedException , IOException {
508
516
boolean remoteCacheFailed =
509
517
BulkTransferException .isOnlyCausedByCacheNotFoundException (exception );
@@ -522,6 +530,7 @@ private SpawnResult handleError(RemoteAction action, IOException exception)
522
530
}
523
531
}
524
532
if (e .isExecutionTimeout ()) {
533
+ maybePrintExecutionMessages (context , e .getResponse ().getMessage (), /* success = */ false );
525
534
return new SpawnResult .Builder ()
526
535
.setRunnerName (getName ())
527
536
.setStatus (Status .TIMEOUT )
0 commit comments