@@ -184,7 +184,6 @@ public static int runMain(String[] argv) {
184
184
Executor .registerErrorHandler ();
185
185
Set <String > subFilePaths = new HashSet <>(); // absolute paths
186
186
Set <String > subFileArgs = new HashSet <>(); // relative to source root
187
- List <Throwable > throwableList = new ArrayList <>();
188
187
int exitCode = 0 ;
189
188
190
189
try {
@@ -421,10 +420,22 @@ public static int runMain(String[] argv) {
421
420
getInstance ().sendToConfigHost (env , webappURI );
422
421
}
423
422
} catch (ParseException e ) {
423
+ // This is likely a problem with processing command line arguments, hence print the error to standard
424
+ // error output.
424
425
System .err .println ("** " + e .getMessage ());
425
426
exitCode = 1 ;
426
427
} catch (IndexerException ex ) {
427
- throwableList .add (ex );
428
+ // The exception(s) were logged already however it does not hurt to reiterate them
429
+ // at the very end of indexing (sans the stack trace) since they might have been buried in the log.
430
+ LOGGER .log (Level .SEVERE , "Indexer failed" , ex );
431
+ int i = 0 ;
432
+ if (ex .getSuppressed ().length > 0 ) {
433
+ LOGGER .log (Level .INFO , "Suppressed exceptions ({0} in total):" , ex .getSuppressed ().length );
434
+ for (Throwable throwable : ex .getSuppressed ()) {
435
+ LOGGER .log (Level .INFO , "{0}: {1}" , new Object []{++i , throwable .getLocalizedMessage ()});
436
+ }
437
+ }
438
+ exitCode = 1 ;
428
439
} catch (Throwable e ) {
429
440
LOGGER .log (Level .SEVERE , "Unexpected Exception" , e );
430
441
System .err .println ("Exception: " + e .getLocalizedMessage ());
@@ -440,17 +451,7 @@ public static int runMain(String[] argv) {
440
451
stats .report (LOGGER , "Indexer finished" , "indexer.total" );
441
452
}
442
453
443
- if (!throwableList .isEmpty ()) {
444
- // The exception(s) were logged already however it does not hurt to reiterate them
445
- // at the very end of indexing (sans the stack trace) since they might have been buried in the log.
446
- LOGGER .log (Level .SEVERE , "Indexer finished with {0} exception{1}" ,
447
- new Object []{throwableList .size (), throwableList .size () > 1 ? "s" : "" });
448
- int i = 0 ;
449
- for (Throwable throwable : throwableList ) {
450
- LOGGER .log (Level .SEVERE , "{0}: {1}" , new Object []{++i , throwable .getLocalizedMessage ()});
451
- }
452
- exitCode = 1 ;
453
- } else {
454
+ if (exitCode == 0 ) {
454
455
LOGGER .log (Level .INFO , "Indexer finished with success" );
455
456
}
456
457
0 commit comments