@@ -1581,7 +1581,10 @@ private static void performBuild(BuildConfiguration config, Function<BuildConfig
15811581 try {
15821582 build (config , nativeImageProvider );
15831583 } catch (NativeImageError e ) {
1584- NativeImage .show (System .err ::println , "Error: " + e .getMessage ());
1584+ String message = e .getMessage ();
1585+ if (message != null ) {
1586+ NativeImage .show (System .err ::println , "Error: " + message );
1587+ }
15851588 Throwable cause = e .getCause ();
15861589 while (cause != null ) {
15871590 NativeImage .show (System .err ::println , "Caused by: " + cause );
@@ -1617,8 +1620,7 @@ protected static void build(BuildConfiguration config, Function<BuildConfigurati
16171620 break ;
16181621 case BUILDER_ERROR :
16191622 /* Exit, builder has handled error reporting. */
1620- System .exit (exitStatusCode );
1621- break ;
1623+ throw showError (null , null , exitStatusCode );
16221624 case FALLBACK_IMAGE :
16231625 nativeImage .showMessage ("Generating fallback image..." );
16241626 build (new FallbackBuildConfiguration (nativeImage ), nativeImageProvider );
@@ -1629,8 +1631,7 @@ protected static void build(BuildConfiguration config, Function<BuildConfigurati
16291631 break ;
16301632 case OUT_OF_MEMORY :
16311633 nativeImage .showOutOfMemoryWarning ();
1632- System .exit (exitStatusCode );
1633- break ;
1634+ throw showError (null , null , exitStatusCode );
16341635 default :
16351636 String message = String .format ("Image build request for '%s' (pid: %d, path: %s) failed with exit status %d" ,
16361637 nativeImage .imageName , nativeImage .imageBuilderPid , nativeImage .imagePath , exitStatusCode );
0 commit comments