Skip to content

Commit ec609c5

Browse files
committed
Ensure bundle gets completed in case of image-build errors
1 parent e2f60d2 commit ec609c5

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

substratevm/src/com.oracle.svm.driver/src/com/oracle/svm/driver/NativeImage.java

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1584,7 +1584,10 @@ private static void performBuild(BuildConfiguration config, Function<BuildConfig
15841584
try {
15851585
build(config, nativeImageProvider);
15861586
} catch (NativeImageError e) {
1587-
NativeImage.show(System.err::println, "Error: " + e.getMessage());
1587+
String message = e.getMessage();
1588+
if (message != null) {
1589+
NativeImage.show(System.err::println, "Error: " + message);
1590+
}
15881591
Throwable cause = e.getCause();
15891592
while (cause != null) {
15901593
NativeImage.show(System.err::println, "Caused by: " + cause);
@@ -1620,8 +1623,7 @@ protected static void build(BuildConfiguration config, Function<BuildConfigurati
16201623
break;
16211624
case BUILDER_ERROR:
16221625
/* Exit, builder has handled error reporting. */
1623-
System.exit(exitStatusCode);
1624-
break;
1626+
throw showError(null, null, exitStatusCode);
16251627
case FALLBACK_IMAGE:
16261628
nativeImage.showMessage("Generating fallback image...");
16271629
build(new FallbackBuildConfiguration(nativeImage), nativeImageProvider);
@@ -1632,8 +1634,7 @@ protected static void build(BuildConfiguration config, Function<BuildConfigurati
16321634
break;
16331635
case OUT_OF_MEMORY:
16341636
nativeImage.showOutOfMemoryWarning();
1635-
System.exit(exitStatusCode);
1636-
break;
1637+
throw showError(null, null, exitStatusCode);
16371638
default:
16381639
String message = String.format("Image build request for '%s' (pid: %d, path: %s) failed with exit status %d",
16391640
nativeImage.imageName, nativeImage.imageBuilderPid, nativeImage.imagePath, exitStatusCode);

0 commit comments

Comments
 (0)