43
43
import java .util .Set ;
44
44
import java .util .TimerTask ;
45
45
import java .util .concurrent .ForkJoinPool ;
46
- import java .util .function .Consumer ;
47
46
import java .util .stream .Collectors ;
48
47
49
48
import org .graalvm .collections .Pair ;
@@ -557,7 +556,7 @@ private int buildImage(ImageClassLoader classLoader) {
557
556
NativeImageGeneratorRunner .reportFatalError (e , "FallbackImageRequest while building fallback image." );
558
557
return ExitStatus .BUILDER_ERROR .getValue ();
559
558
}
560
- reportUserException (e , parsedHostedOptions , LogUtils :: warning );
559
+ reportUserException (e , parsedHostedOptions );
561
560
return ExitStatus .FALLBACK_IMAGE .getValue ();
562
561
} catch (ParsingError e ) {
563
562
NativeImageGeneratorRunner .reportFatalError (e );
@@ -584,7 +583,7 @@ private int buildImage(ImageClassLoader classLoader) {
584
583
}
585
584
586
585
if (pee .getExceptions ().size () > 1 ) {
587
- System .err .println (pee .getExceptions ().size () + " fatal errors detected:" );
586
+ System .out .println (pee .getExceptions ().size () + " fatal errors detected:" );
588
587
}
589
588
for (Throwable exception : pee .getExceptions ()) {
590
589
NativeImageGeneratorRunner .reportFatalError (exception );
@@ -670,8 +669,8 @@ public static void printCPUFeatures(Platform platform) {
670
669
* @param e error to be reported.
671
670
*/
672
671
protected static void reportFatalError (Throwable e ) {
673
- System .err .print ("Fatal error: " );
674
- e .printStackTrace ();
672
+ System .out .print ("Fatal error: " );
673
+ e .printStackTrace (System . out );
675
674
}
676
675
677
676
/**
@@ -681,8 +680,8 @@ protected static void reportFatalError(Throwable e) {
681
680
* @param msg message to report.
682
681
*/
683
682
protected static void reportFatalError (Throwable e , String msg ) {
684
- System .err .print ("Fatal error: " + msg );
685
- e .printStackTrace ();
683
+ System .out .print ("Fatal error: " + msg );
684
+ e .printStackTrace (System . out );
686
685
}
687
686
688
687
/**
@@ -691,7 +690,7 @@ protected static void reportFatalError(Throwable e, String msg) {
691
690
* @param msg error message that is printed.
692
691
*/
693
692
public static void reportUserError (String msg ) {
694
- System .err .println ("Error: " + msg );
693
+ System .out .println ("Error: " + msg );
695
694
}
696
695
697
696
/**
@@ -701,20 +700,28 @@ public static void reportUserError(String msg) {
701
700
* @param parsedHostedOptions
702
701
*/
703
702
public static void reportUserError (Throwable e , OptionValues parsedHostedOptions ) {
704
- reportUserException (e , parsedHostedOptions , NativeImageGeneratorRunner :: reportUserError );
703
+ reportUserException (e , parsedHostedOptions );
705
704
}
706
705
707
- private static void reportUserException (Throwable e , OptionValues parsedHostedOptions , Consumer < String > report ) {
706
+ private static void reportUserException (Throwable e , OptionValues parsedHostedOptions ) {
708
707
if (e instanceof UserException ue ) {
709
708
for (String message : ue .getMessages ()) {
710
- report . accept (message );
709
+ reportUserError (message );
711
710
}
712
711
} else {
713
- report .accept (e .getMessage ());
712
+ reportUserError (e .getMessage ());
713
+ }
714
+ Throwable current = e .getCause ();
715
+ while (current != null ) {
716
+ System .out .print ("Caused by: " );
717
+ current .printStackTrace (System .out );
718
+ current = current .getCause ();
714
719
}
715
720
if (parsedHostedOptions != null && NativeImageOptions .ReportExceptionStackTraces .getValue (parsedHostedOptions )) {
716
- e .printStackTrace ();
721
+ System .out .print ("Internal exception: " );
722
+ e .printStackTrace (System .out );
717
723
}
724
+ System .out .flush ();
718
725
}
719
726
720
727
public int build (ImageClassLoader imageClassLoader ) {
0 commit comments