@@ -184,7 +184,6 @@ public static int runMain(String[] argv) {
184184 Executor .registerErrorHandler ();
185185 Set <String > subFilePaths = new HashSet <>(); // absolute paths
186186 Set <String > subFileArgs = new HashSet <>(); // relative to source root
187- List <Throwable > throwableList = new ArrayList <>();
188187 int exitCode = 0 ;
189188
190189 try {
@@ -421,10 +420,22 @@ public static int runMain(String[] argv) {
421420 getInstance ().sendToConfigHost (env , webappURI );
422421 }
423422 } catch (ParseException e ) {
423+ // This is likely a problem with processing command line arguments, hence print the error to standard
424+ // error output.
424425 System .err .println ("** " + e .getMessage ());
425426 exitCode = 1 ;
426427 } 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 ;
428439 } catch (Throwable e ) {
429440 LOGGER .log (Level .SEVERE , "Unexpected Exception" , e );
430441 System .err .println ("Exception: " + e .getLocalizedMessage ());
@@ -440,17 +451,7 @@ public static int runMain(String[] argv) {
440451 stats .report (LOGGER , "Indexer finished" , "indexer.total" );
441452 }
442453
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 ) {
454455 LOGGER .log (Level .INFO , "Indexer finished with success" );
455456 }
456457
0 commit comments