8217751: jpackage messages and failures JDK-8200758-branch
authorherrick
Sun, 03 Feb 2019 08:16:08 -0500
branchJDK-8200758-branch
changeset 57140 3dcb33ce7ced
parent 57127 1e4dceb0da58
child 57141 e7ba8c89abe7
8217751: jpackage messages and failures Reviewed-by: almatvee
src/jdk.jpackage/linux/classes/jdk/jpackage/internal/LinuxAppBundler.java
src/jdk.jpackage/linux/classes/jdk/jpackage/internal/LinuxDebBundler.java
src/jdk.jpackage/linux/classes/jdk/jpackage/internal/LinuxRpmBundler.java
src/jdk.jpackage/macosx/classes/jdk/jpackage/internal/MacAppBundler.java
src/jdk.jpackage/macosx/classes/jdk/jpackage/internal/MacAppStoreBundler.java
src/jdk.jpackage/macosx/classes/jdk/jpackage/internal/MacBaseInstallerBundler.java
src/jdk.jpackage/macosx/classes/jdk/jpackage/internal/MacDmgBundler.java
src/jdk.jpackage/macosx/classes/jdk/jpackage/internal/MacPkgBundler.java
src/jdk.jpackage/share/classes/jdk/jpackage/internal/AbstractImageBundler.java
src/jdk.jpackage/share/classes/jdk/jpackage/internal/Arguments.java
src/jdk.jpackage/share/classes/jdk/jpackage/internal/Bundler.java
src/jdk.jpackage/share/classes/jdk/jpackage/internal/resources/MainResources.properties
src/jdk.jpackage/share/classes/jdk/jpackage/internal/resources/MainResources_ja.properties
src/jdk.jpackage/share/classes/jdk/jpackage/internal/resources/MainResources_zh_CN.properties
src/jdk.jpackage/windows/classes/jdk/jpackage/internal/WinAppBundler.java
src/jdk.jpackage/windows/classes/jdk/jpackage/internal/WinExeBundler.java
src/jdk.jpackage/windows/classes/jdk/jpackage/internal/WinMsiBundler.java
test/jdk/tools/jpackage/JPackageInvalidArgTest.java
--- a/src/jdk.jpackage/linux/classes/jdk/jpackage/internal/LinuxAppBundler.java	Wed Jan 30 19:48:18 2019 -0500
+++ b/src/jdk.jpackage/linux/classes/jdk/jpackage/internal/LinuxAppBundler.java	Sun Feb 03 08:16:08 2019 -0500
@@ -130,7 +130,7 @@
     }
 
     File doBundle(Map<String, ? super Object> p, File outputDirectory,
-            boolean dependentTask) {
+            boolean dependentTask) throws PackagerException {
         if (Arguments.CREATE_JRE_INSTALLER.fetchFrom(p)) {
             return doJreBundle(p, outputDirectory, dependentTask);
         } else {
@@ -139,7 +139,7 @@
     }
 
     private File doJreBundle(Map<String, ? super Object> p,
-            File outputDirectory, boolean dependentTask) {
+            File outputDirectory, boolean dependentTask) throws PackagerException {
         try {
             File rootDirectory = createRoot(p, outputDirectory, dependentTask,
                     APP_NAME.fetchFrom(p), "linuxapp-image-builder");
@@ -152,15 +152,16 @@
                 return predefined;
             }
             return rootDirectory;
+        } catch (PackagerException pe) {
+            throw pe;
         } catch (Exception ex) {
-            Log.error("Exception: "+ex);
-            Log.debug(ex);
-            return null;
+            Log.verbose(ex);
+            throw new PackagerException(ex);
         }
     }
 
     private File doAppBundle(Map<String, ? super Object> p,
-            File outputDirectory, boolean dependentTask) {
+            File outputDirectory, boolean dependentTask) throws PackagerException {
         try {
             File rootDirectory = createRoot(p, outputDirectory, dependentTask,
                     APP_NAME.fetchFrom(p), "linuxapp-image-builder");
@@ -172,10 +173,11 @@
                 StandardBundlerParam.copyPredefinedRuntimeImage(p, appBuilder);
             }
             return rootDirectory;
+        } catch (PackagerException pe) {
+            throw pe;
         } catch (Exception ex) {
-            Log.error("Exception: "+ex);
-            Log.debug(ex);
-            return null;
+            Log.verbose(ex);
+            throw new PackagerException(ex);
         }
     }
 
@@ -221,7 +223,7 @@
 
     @Override
     public File execute(Map<String, ? super Object> params,
-            File outputParentDir) {
+            File outputParentDir) throws PackagerException {
         return doBundle(params, outputParentDir, false);
     }
 
--- a/src/jdk.jpackage/linux/classes/jdk/jpackage/internal/LinuxDebBundler.java	Wed Jan 30 19:48:18 2019 -0500
+++ b/src/jdk.jpackage/linux/classes/jdk/jpackage/internal/LinuxDebBundler.java	Sun Feb 03 08:16:08 2019 -0500
@@ -171,9 +171,7 @@
                         return Files.readString(new File(licenseFile).toPath());
                     }
                 } catch (Exception e) {
-                    if (Log.isDebug()) {
-                        e.printStackTrace();
-                    }
+                    Log.verbose(e);
                 }
                 return "Unknown";
             },
@@ -197,9 +195,7 @@
 
                     return (appName + "-" + vendor).replaceAll("\\s", "");
                 } catch (Exception e) {
-                    if (Log.isDebug()) {
-                        e.printStackTrace();
-                    }
+                    Log.verbose(e);
                 }
                 return "unknown-MimeInfo.xml";
             },
@@ -301,7 +297,7 @@
     }
 
     private boolean prepareProto(Map<String, ? super Object> p)
-            throws IOException {
+            throws PackagerException, IOException {
         File appImage = StandardBundlerParam.getPredefinedAppImage(p);
         File appDir = null;
 
@@ -319,16 +315,15 @@
     }
 
     //@Override
-    public File bundle(Map<String, ? super Object> p, File outdir) {
+    public File bundle(Map<String, ? super Object> p,
+            File outdir) throws PackagerException {
         if (!outdir.isDirectory() && !outdir.mkdirs()) {
-            throw new RuntimeException(MessageFormat.format(
-                    I18N.getString("error.cannot-create-output-dir"),
-                    outdir.getAbsolutePath()));
+            throw new PackagerException ("error.cannot-create-output-dir",
+                    outdir.getAbsolutePath());
         }
         if (!outdir.canWrite()) {
-            throw new RuntimeException(MessageFormat.format(
-                    I18N.getString("error.cannot-write-to-output-dir"),
-                    outdir.getAbsolutePath()));
+            throw new PackagerException("error.cannot-write-to-output-dir",
+                    outdir.getAbsolutePath());
         }
 
         // we want to create following structure
@@ -355,8 +350,8 @@
             }
             return null;
         } catch (IOException ex) {
-            ex.printStackTrace();
-            return null;
+            Log.verbose(ex);
+            throw new PackagerException(ex);
         }
     }
 
@@ -874,7 +869,7 @@
 
     @Override
     public File execute(Map<String, ? super Object> params,
-            File outputParentDir) {
+            File outputParentDir) throws PackagerException {
         return bundle(params, outputParentDir);
     }
 
@@ -892,7 +887,7 @@
                 return 0;
             }
         } catch (Exception e) {
-            e.printStackTrace();
+            Log.verbose(e);
             return 0;
         }
     }
--- a/src/jdk.jpackage/linux/classes/jdk/jpackage/internal/LinuxRpmBundler.java	Wed Jan 30 19:48:18 2019 -0500
+++ b/src/jdk.jpackage/linux/classes/jdk/jpackage/internal/LinuxRpmBundler.java	Sun Feb 03 08:16:08 2019 -0500
@@ -237,7 +237,7 @@
     }
 
     private boolean prepareProto(Map<String, ? super Object> p)
-            throws IOException {
+            throws PackagerException, IOException {
         File appImage = StandardBundlerParam.getPredefinedAppImage(p);
         File appDir = null;
 
@@ -254,16 +254,17 @@
         return appDir != null;
     }
 
-    public File bundle(Map<String, ? super Object> p, File outdir) {
+    public File bundle(Map<String, ? super Object> p,
+            File outdir) throws PackagerException {
         if (!outdir.isDirectory() && !outdir.mkdirs()) {
-            throw new RuntimeException(MessageFormat.format(
-                    I18N.getString("error.cannot-create-output-dir"),
-                    outdir.getAbsolutePath()));
+            throw new PackagerException(
+                    "error.cannot-create-output-dir",
+                    outdir.getAbsolutePath());
         }
         if (!outdir.canWrite()) {
-            throw new RuntimeException(MessageFormat.format(
-                    I18N.getString("error.cannot-write-to-output-dir"),
-                    outdir.getAbsolutePath()));
+            throw new PackagerException(
+                    "error.cannot-write-to-output-dir",
+                    outdir.getAbsolutePath());
         }
 
         File imageDir = RPM_IMAGE_DIR.fetchFrom(p);
@@ -276,8 +277,8 @@
             }
             return null;
         } catch (IOException ex) {
-            ex.printStackTrace();
-            return null;
+            Log.verbose(ex);
+            throw new PackagerException(ex);
         }
     }
 
@@ -701,8 +702,8 @@
     }
 
     @Override
-    public File execute(
-            Map<String, ? super Object> params, File outputParentDir) {
+    public File execute(Map<String, ? super Object> params,
+            File outputParentDir) throws PackagerException {
         return bundle(params, outputParentDir);
     }
 
--- a/src/jdk.jpackage/macosx/classes/jdk/jpackage/internal/MacAppBundler.java	Wed Jan 30 19:48:18 2019 -0500
+++ b/src/jdk.jpackage/macosx/classes/jdk/jpackage/internal/MacAppBundler.java	Sun Feb 03 08:16:08 2019 -0500
@@ -305,7 +305,7 @@
     }
 
     File doBundle(Map<String, ? super Object> p, File outputDirectory,
-            boolean dependentTask) {
+            boolean dependentTask) throws PackagerException {
         if (Arguments.CREATE_JRE_INSTALLER.fetchFrom(p)) {
             return doJreBundle(p, outputDirectory, dependentTask);
         } else {
@@ -313,8 +313,8 @@
         }
     }
 
-    File doJreBundle(Map<String, ? super Object> p,
-            File outputDirectory, boolean dependentTask) {
+    File doJreBundle(Map<String, ? super Object> p, File outputDirectory,
+            boolean dependentTask) throws PackagerException {
         try {
             File rootDirectory = createRoot(p, outputDirectory, dependentTask,
                     APP_NAME.fetchFrom(p), "macapp-image-builder");
@@ -327,15 +327,16 @@
                 return predefined;
             }
             return rootDirectory;
+        } catch (PackagerException pe) {
+            throw pe;
         } catch (Exception ex) {
-            Log.error("Exception: "+ex);
             Log.verbose(ex);
-            return null;
+            throw new PackagerException(ex);
         }
     }
 
     File doAppBundle(Map<String, ? super Object> p, File outputDirectory,
-            boolean dependentTask) {
+            boolean dependentTask) throws PackagerException {
         try {
             File rootDirectory = createRoot(p, outputDirectory, dependentTask,
                     APP_NAME.fetchFrom(p) + ".app", "macapp-image-builder");
@@ -347,10 +348,11 @@
                 StandardBundlerParam.copyPredefinedRuntimeImage(p, appBuilder);
             }
             return rootDirectory;
+        } catch (PackagerException pe) {
+            throw pe;
         } catch (Exception ex) {
-            Log.error("Exception: "+ex);
             Log.verbose(ex);
-            return null;
+            throw new PackagerException(ex);
         }
     }
 
@@ -409,7 +411,7 @@
 
     @Override
     public File execute(Map<String, ? super Object> params,
-            File outputParentDir) {
+            File outputParentDir) throws PackagerException {
         return doBundle(params, outputParentDir, false);
     }
 
--- a/src/jdk.jpackage/macosx/classes/jdk/jpackage/internal/MacAppStoreBundler.java	Wed Jan 30 19:48:18 2019 -0500
+++ b/src/jdk.jpackage/macosx/classes/jdk/jpackage/internal/MacAppStoreBundler.java	Sun Feb 03 08:16:08 2019 -0500
@@ -126,18 +126,19 @@
             (s, p) -> s);
 
     //@Override
-    public File bundle(Map<String, ? super Object> p, File outdir) {
+    public File bundle(Map<String, ? super Object> p,
+            File outdir) throws PackagerException {
         Log.verbose(MessageFormat.format(I18N.getString(
                 "message.building-bundle"), APP_NAME.fetchFrom(p)));
         if (!outdir.isDirectory() && !outdir.mkdirs()) {
-            throw new RuntimeException(MessageFormat.format(I18N.getString(
-                    "error.cannot-create-output-dir"),
-                     outdir.getAbsolutePath()));
+            throw new PackagerException(
+                    "error.cannot-create-output-dir",
+                     outdir.getAbsolutePath());
         }
         if (!outdir.canWrite()) {
-            throw new RuntimeException(MessageFormat.format(I18N.getString(
-                    "error.cannot-write-to-output-dir"),
-                    outdir.getAbsolutePath()));
+            throw new PackagerException(
+                    "error.cannot-write-to-output-dir",
+                    outdir.getAbsolutePath());
         }
 
         // first, load in some overrides
@@ -202,10 +203,11 @@
 
             IOUtils.exec(pb, false);
             return finalPKG;
+        } catch (PackagerException pe) {
+            throw pe;
         } catch (Exception ex) {
-            Log.error("App Store Ready Bundle failed : " + ex.getMessage());
             Log.verbose(ex);
-            return null;
+            throw new PackagerException(ex);
         }
     }
 
@@ -361,7 +363,7 @@
 
     @Override
     public File execute(Map<String, ? super Object> params,
-            File outputParentDir) {
+            File outputParentDir) throws PackagerException {
         return bundle(params, outputParentDir);
     }
 
--- a/src/jdk.jpackage/macosx/classes/jdk/jpackage/internal/MacBaseInstallerBundler.java	Wed Jan 30 19:48:18 2019 -0500
+++ b/src/jdk.jpackage/macosx/classes/jdk/jpackage/internal/MacBaseInstallerBundler.java	Sun Feb 03 08:16:08 2019 -0500
@@ -145,8 +145,8 @@
         }
     }
 
-    protected File prepareAppBundle(
-            Map<String, ? super Object> p, boolean pkg) {
+    protected File prepareAppBundle(Map<String, ? super Object> p,
+            boolean pkg) throws PackagerException {
         File predefinedImage = StandardBundlerParam.getPredefinedAppImage(p);
         if (predefinedImage != null) {
             return predefinedImage;
--- a/src/jdk.jpackage/macosx/classes/jdk/jpackage/internal/MacDmgBundler.java	Wed Jan 30 19:48:18 2019 -0500
+++ b/src/jdk.jpackage/macosx/classes/jdk/jpackage/internal/MacDmgBundler.java	Sun Feb 03 08:16:08 2019 -0500
@@ -52,18 +52,19 @@
             params -> "",
             (s, p) -> s);
 
-    public File bundle(Map<String, ? super Object> params, File outdir) {
+    public File bundle(Map<String, ? super Object> params,
+            File outdir) throws PackagerException {
         Log.verbose(MessageFormat.format(I18N.getString("message.building-dmg"),
                 APP_NAME.fetchFrom(params)));
         if (!outdir.isDirectory() && !outdir.mkdirs()) {
-            throw new RuntimeException(MessageFormat.format(
-                    I18N.getString("error.cannot-create-output-dir"),
-                    outdir.getAbsolutePath()));
+            throw new PackagerException(
+                    "error.cannot-create-output-dir",
+                    outdir.getAbsolutePath());
         }
         if (!outdir.canWrite()) {
-            throw new RuntimeException(MessageFormat.format(
-                    I18N.getString("error.cannot-write-to-output-dir"),
-                    outdir.getAbsolutePath()));
+            throw new PackagerException(
+                    "error.cannot-write-to-output-dir",
+                    outdir.getAbsolutePath());
         }
 
         File appImageDir = APP_IMAGE_BUILD_ROOT.fetchFrom(params);
@@ -85,7 +86,7 @@
             return null;
         } catch (IOException ex) {
             Log.verbose(ex);
-            return null;
+            throw new PackagerException(ex);
         }
     }
 
@@ -472,8 +473,8 @@
     }
 
     @Override
-    public File execute(
-            Map<String, ? super Object> params, File outputParentDir) {
+    public File execute(Map<String, ? super Object> params,
+            File outputParentDir) throws PackagerException {
         return bundle(params, outputParentDir);
     }
 
--- a/src/jdk.jpackage/macosx/classes/jdk/jpackage/internal/MacPkgBundler.java	Wed Jan 30 19:48:18 2019 -0500
+++ b/src/jdk.jpackage/macosx/classes/jdk/jpackage/internal/MacPkgBundler.java	Sun Feb 03 08:16:08 2019 -0500
@@ -139,18 +139,19 @@
             params -> "",
             (s, p) -> s);
 
-    public File bundle(Map<String, ? super Object> params, File outdir) {
+    public File bundle(Map<String, ? super Object> params,
+            File outdir) throws PackagerException {
         Log.verbose(MessageFormat.format(I18N.getString("message.building-pkg"),
                 APP_NAME.fetchFrom(params)));
         if (!outdir.isDirectory() && !outdir.mkdirs()) {
-            throw new RuntimeException(MessageFormat.format(
-                    I18N.getString("error.cannot-create-output-dir"),
-                    outdir.getAbsolutePath()));
+            throw new PackagerException(
+                    "error.cannot-create-output-dir",
+                    outdir.getAbsolutePath());
         }
         if (!outdir.canWrite()) {
-            throw new RuntimeException(MessageFormat.format(
-                    I18N.getString("error.cannot-write-to-output-dir"),
-                    outdir.getAbsolutePath()));
+            throw new PackagerException(
+                    "error.cannot-write-to-output-dir",
+                    outdir.getAbsolutePath());
         }
 
         File appImageDir = null;
@@ -172,7 +173,7 @@
             return null;
         } catch (IOException ex) {
             Log.verbose(ex);
-            return null;
+            throw new PackagerException(ex);
         }
     }
 
@@ -488,8 +489,8 @@
     }
 
     @Override
-    public File execute(
-        Map<String, ? super Object> params, File outputParentDir) {
+    public File execute(Map<String, ? super Object> params,
+            File outputParentDir) throws PackagerException {
         return bundle(params, outputParentDir);
     }
 
--- a/src/jdk.jpackage/share/classes/jdk/jpackage/internal/AbstractImageBundler.java	Wed Jan 30 19:48:18 2019 -0500
+++ b/src/jdk.jpackage/share/classes/jdk/jpackage/internal/AbstractImageBundler.java	Sun Feb 03 08:16:08 2019 -0500
@@ -122,7 +122,7 @@
 
     protected File createRoot(Map<String, ? super Object> p,
             File outputDirectory, boolean dependentTask,
-            String name, String jlinkKey) throws IOException {
+            String name, String jlinkKey) throws PackagerException {
         if (!outputDirectory.isDirectory() && !outputDirectory.mkdirs()) {
             throw new RuntimeException(MessageFormat.format(
                     I18N.getString("error.cannot-create-output-dir"),
@@ -144,11 +144,14 @@
 
         if (rootDirectory.exists()) {
             if (!(FORCE.fetchFrom(p))) {
-                throw new IOException(MessageFormat.format(
-                        I18N.getString("error.root-exists-without-force"),
-                        rootDirectory.getAbsolutePath()));
+                throw new PackagerException("error.root-exists-without-force",
+                        rootDirectory.getAbsolutePath());
             }
-            IOUtils.deleteRecursive(rootDirectory);
+            try {
+                IOUtils.deleteRecursive(rootDirectory);
+            } catch (IOException ioe) {
+                throw new PackagerException(ioe);
+            }
         }
         rootDirectory.mkdirs();
 
--- a/src/jdk.jpackage/share/classes/jdk/jpackage/internal/Arguments.java	Wed Jan 30 19:48:18 2019 -0500
+++ b/src/jdk.jpackage/share/classes/jdk/jpackage/internal/Arguments.java	Sun Feb 03 08:16:08 2019 -0500
@@ -151,7 +151,7 @@
         });
     }
 
-    public Arguments(String[] args) {
+    public Arguments(String[] args) throws PackagerException {
         initArgumentList(args);
     }
 
@@ -516,7 +516,7 @@
         PLATFORM_LINUX;
     }
 
-    private void initArgumentList(String[] args) {
+    private void initArgumentList(String[] args) throws PackagerException {
         argList = new ArrayList<String>(args.length);
         for (String arg : args) {
             if (arg.startsWith("@")) {
@@ -524,7 +524,7 @@
                     String filename = arg.substring(1);
                     argList.addAll(extractArgList(filename));
                 } else {
-                    Log.error("invalid option ["+arg+"]");
+                    throw new PackagerException("ERR_InvalidOption", arg);
                 }
             } else {
                 argList.add(arg);
@@ -597,7 +597,7 @@
                     allOptions.add(option);
                     option.execute();
                 } else {
-                    Log.error("invalid option ["+arg+"]");
+                    throw new PackagerException("ERR_InvalidOption", arg);
                 }
             }
 
@@ -688,9 +688,8 @@
         CLIOptions mode = allOptions.get(0);
         for (CLIOptions option : allOptions) {
             if(!ValidOptions.checkIfSupported(mode, option)) {
-              System.out.println("WARNING: argument ["
-                      + option.getId() + "] is not "
-                      + "supported for current configuration.");
+                Log.info(MessageFormat.format(I18N.getString(
+                        "warning.unsupported.option"), option.getId(), mode));
             }
         }
     }
@@ -747,25 +746,24 @@
                     bundleCreated = true; // at least one bundle was created
                 }
             } catch (UnsupportedPlatformException e) {
-                Log.debug(MessageFormat.format(
-                        I18N.getString("MSG_BundlerPlatformException"),
-                        bundler.getName()));
+                throw new PackagerException(e,
+                        "MSG_BundlerPlatformException",
+                        bundler.getName());
             } catch (ConfigException e) {
                 Log.debug(e);
                 if (e.getAdvice() != null) {
-                    Log.error(MessageFormat.format(
-                            I18N.getString("MSG_BundlerConfigException"),
-                            bundler.getName(), e.getMessage(), e.getAdvice()));
+                    throw new PackagerException(e,
+                            "MSG_BundlerConfigException",
+                            bundler.getName(), e.getMessage(), e.getAdvice());
                 } else {
-                    Log.error(MessageFormat.format(I18N.getString(
-                            "MSG_BundlerConfigExceptionNoAdvice"),
-                            bundler.getName(), e.getMessage()));
+                    throw new PackagerException(e,
+                           "MSG_BundlerConfigExceptionNoAdvice",
+                            bundler.getName(), e.getMessage());
                 }
             } catch (RuntimeException re) {
-                Log.error(MessageFormat.format(
-                        I18N.getString("MSG_BundlerRuntimeException"),
-                        bundler.getName(), re.toString()));
                 Log.debug(re);
+                throw new PackagerException(re, "MSG_BundlerRuntimeException",
+                        bundler.getName(), re.toString());
             } finally {
                 if (retainBuildRoot) {
                     Log.verbose(MessageFormat.format(
--- a/src/jdk.jpackage/share/classes/jdk/jpackage/internal/Bundler.java	Wed Jan 30 19:48:18 2019 -0500
+++ b/src/jdk.jpackage/share/classes/jdk/jpackage/internal/Bundler.java	Sun Feb 03 08:16:08 2019 -0500
@@ -118,8 +118,8 @@
      *      forward slashes.</li>
      *  </ul>
      */
-    public File execute(
-            Map<String, ? super Object> params, File outputParentDir);
+    public File execute(Map<String, ? super Object> params,
+            File outputParentDir) throws PackagerException;
 
      /**
      * Removes temporary files that are used for bundling.
--- a/src/jdk.jpackage/share/classes/jdk/jpackage/internal/resources/MainResources.properties	Wed Jan 30 19:48:18 2019 -0500
+++ b/src/jdk.jpackage/share/classes/jdk/jpackage/internal/resources/MainResources.properties	Sun Feb 03 08:16:08 2019 -0500
@@ -137,7 +137,7 @@
 
 error.cannot-create-output-dir=Output directory {0} cannot be created.
 error.cannot-write-to-output-dir=Output directory {0} is not writable.
-error.root-exists-without-force=Root Directory {0} already exists and --force is not specified"
+error.root-exists-without-force=Error: Output root directory {0} already exists and --force is not specified"
 error.no-application-class=Main application class is missing.
 error.no-application-class.advice=Please specify main application class.
 error.no-main-module=Main application module is missing.
@@ -151,6 +151,7 @@
 
 warning.module.does.not.exist=Module {0} does not exist.
 warning.no.jdk.modules.found=Warning: No JDK Modules found.
+warning.unsupported.option=Warning: Option [{0}] is not supported in {1} mode on this platform.
 
 MSG_BundlerFailed=Error: Bundler "{1}" ({0}) failed to produce a bundle.
 MSG_BundlerPlatformException=Bundler {0} skipped because the bundler does not support bundling on this platform.
@@ -161,6 +162,8 @@
 MSG_Version=jpackage version
 MSG_BundlerFailed=Error: Bundler "{1}" ({0}) failed to produce a bundle.
 
+
+
 ERR_MissingArgument=Error: Missing argument: {0}
 ERR_MissingAppResources=Error: No application jars found
 ERR_AppImageNotExist=Error: App image directory "{0}" does not exist
@@ -172,3 +175,4 @@
 ERR_InvalidSLName=Error: Invalid Secondary Launcher name: {0}.
 ERR_LicenseFileNotExit=Error: Specified license file does not exist.
 ERR_BuildRootInvalid=Error: build-root ({0}) must be empty directory.
+ERR_InvalidOption=Error: Invalid Option: [{0}]
--- a/src/jdk.jpackage/share/classes/jdk/jpackage/internal/resources/MainResources_ja.properties	Wed Jan 30 19:48:18 2019 -0500
+++ b/src/jdk.jpackage/share/classes/jdk/jpackage/internal/resources/MainResources_ja.properties	Sun Feb 03 08:16:08 2019 -0500
@@ -137,7 +137,7 @@
 
 error.cannot-create-output-dir=Output directory {0} cannot be created.
 error.cannot-write-to-output-dir=Output directory {0} is not writable.
-error.root-exists-without-force=Root Directory {0} already exists and --force is not specified"
+error.root-exists-without-force=Error: Output root directory {0} already exists and --force is not specified"
 error.no-application-class=Main application class is missing.
 error.no-application-class.advice=Please specify main application class.
 error.no-main-module=Main application module is missing.
@@ -151,6 +151,7 @@
 
 warning.module.does.not.exist=Module {0} does not exist.
 warning.no.jdk.modules.found=Warning: No JDK Modules found.
+warning.unsupported.option=Warning: Option [{0}] is not supported in {1} mode on this platform.
 
 MSG_BundlerFailed=Error: Bundler "{1}" ({0}) failed to produce a bundle.
 MSG_BundlerPlatformException=Bundler {0} skipped because the bundler does not support bundling on this platform.
@@ -161,6 +162,8 @@
 MSG_Version=jpackage version
 MSG_BundlerFailed=Error: Bundler "{1}" ({0}) failed to produce a bundle.
 
+
+
 ERR_MissingArgument=Error: Missing argument: {0}
 ERR_MissingAppResources=Error: No application jars found
 ERR_AppImageNotExist=Error: App image directory "{0}" does not exist
@@ -172,3 +175,4 @@
 ERR_InvalidSLName=Error: Invalid Secondary Launcher name: {0}.
 ERR_LicenseFileNotExit=Error: Specified license file does not exist.
 ERR_BuildRootInvalid=Error: build-root ({0}) must be empty directory.
+ERR_InvalidOption=Error: Invalid Option: [{0}]
--- a/src/jdk.jpackage/share/classes/jdk/jpackage/internal/resources/MainResources_zh_CN.properties	Wed Jan 30 19:48:18 2019 -0500
+++ b/src/jdk.jpackage/share/classes/jdk/jpackage/internal/resources/MainResources_zh_CN.properties	Sun Feb 03 08:16:08 2019 -0500
@@ -137,7 +137,7 @@
 
 error.cannot-create-output-dir=Output directory {0} cannot be created.
 error.cannot-write-to-output-dir=Output directory {0} is not writable.
-error.root-exists-without-force=Root Directory {0} already exists and --force is not specified"
+error.root-exists-without-force=Error: Output root directory {0} already exists and --force is not specified"
 error.no-application-class=Main application class is missing.
 error.no-application-class.advice=Please specify main application class.
 error.no-main-module=Main application module is missing.
@@ -151,6 +151,7 @@
 
 warning.module.does.not.exist=Module {0} does not exist.
 warning.no.jdk.modules.found=Warning: No JDK Modules found.
+warning.unsupported.option=Warning: Option [{0}] is not supported in {1} mode on this platform.
 
 MSG_BundlerFailed=Error: Bundler "{1}" ({0}) failed to produce a bundle.
 MSG_BundlerPlatformException=Bundler {0} skipped because the bundler does not support bundling on this platform.
@@ -161,6 +162,8 @@
 MSG_Version=jpackage version
 MSG_BundlerFailed=Error: Bundler "{1}" ({0}) failed to produce a bundle.
 
+
+
 ERR_MissingArgument=Error: Missing argument: {0}
 ERR_MissingAppResources=Error: No application jars found
 ERR_AppImageNotExist=Error: App image directory "{0}" does not exist
@@ -172,3 +175,4 @@
 ERR_InvalidSLName=Error: Invalid Secondary Launcher name: {0}.
 ERR_LicenseFileNotExit=Error: Specified license file does not exist.
 ERR_BuildRootInvalid=Error: build-root ({0}) must be empty directory.
+ERR_InvalidOption=Error: Invalid Option: [{0}]
--- a/src/jdk.jpackage/windows/classes/jdk/jpackage/internal/WinAppBundler.java	Wed Jan 30 19:48:18 2019 -0500
+++ b/src/jdk.jpackage/windows/classes/jdk/jpackage/internal/WinAppBundler.java	Sun Feb 03 08:16:08 2019 -0500
@@ -168,12 +168,13 @@
         return "app\\" + getAppName(p) +".cfg";
     }
 
-    public boolean bundle(Map<String, ? super Object> p, File outputDirectory) {
+    public boolean bundle(Map<String, ? super Object> p, File outputDirectory)
+            throws PackagerException {
         return doBundle(p, outputDirectory, false) != null;
     }
 
-    File doBundle(Map<String, ? super Object> p,
-                File outputDirectory, boolean dependentTask) {
+    File doBundle(Map<String, ? super Object> p, File outputDirectory,
+            boolean dependentTask) throws PackagerException {
         if (Arguments.CREATE_JRE_INSTALLER.fetchFrom(p)) {
             return doJreBundle(p, outputDirectory, dependentTask);
         } else {
@@ -181,8 +182,8 @@
         }
     }
 
-    File doJreBundle(Map<String, ? super Object> p,
-            File outputDirectory, boolean dependentTask) {
+    File doJreBundle(Map<String, ? super Object> p, File outputDirectory,
+            boolean dependentTask) throws PackagerException {
         try {
             File rootDirectory = createRoot(p, outputDirectory, dependentTask,
                 APP_NAME.fetchFrom(p), "windowsapp-image-builder");
@@ -196,15 +197,16 @@
                 return predefined;
             }
             return rootDirectory;
-        } catch (Exception ex) {
-            Log.error("Exception: "+ex);
-            Log.verbose(ex);
-            return null;
+        } catch (PackagerException pe) {
+            throw pe;
+        } catch (Exception e) {
+            Log.verbose(e);
+            throw new PackagerException(e);
         }
     }
 
-    File doAppBundle(Map<String, ? super Object> p,
-            File outputDirectory, boolean dependentTask) {
+    File doAppBundle(Map<String, ? super Object> p, File outputDirectory,
+            boolean dependentTask) throws PackagerException {
         try {
             File rootDirectory = createRoot(p, outputDirectory, dependentTask,
                     APP_NAME.fetchFrom(p), "windowsapp-image-builder");
@@ -221,10 +223,11 @@
                         outputDirectory.getAbsolutePath()));
             }
             return rootDirectory;
-        } catch (Exception ex) {
-            Log.error("Exception: "+ex);
-            Log.verbose(ex);
-            return null;
+        } catch (PackagerException pe) {
+            throw pe;
+        } catch (Exception e) {
+            Log.verbose(e);
+            throw new PackagerException(e);
         }
     }
 
@@ -300,8 +303,8 @@
     }
 
     @Override
-    public File execute(
-            Map<String, ? super Object> params, File outputParentDir) {
+    public File execute(Map<String, ? super Object> params,
+            File outputParentDir) throws PackagerException {
         return doBundle(params, outputParentDir, false);
     }
 
--- a/src/jdk.jpackage/windows/classes/jdk/jpackage/internal/WinExeBundler.java	Wed Jan 30 19:48:18 2019 -0500
+++ b/src/jdk.jpackage/windows/classes/jdk/jpackage/internal/WinExeBundler.java	Sun Feb 03 08:16:08 2019 -0500
@@ -190,8 +190,8 @@
     }
 
     @Override
-    public File execute(
-            Map<String, ? super Object> p, File outputParentDir) {
+    public File execute(Map<String, ? super Object> p,
+            File outputParentDir) throws PackagerException {
         return bundle(p, outputParentDir);
     }
 
@@ -328,7 +328,7 @@
     }
 
     private boolean prepareProto(Map<String, ? super Object> p)
-                throws IOException {
+                throws PackagerException, IOException {
         File appImage = StandardBundlerParam.getPredefinedAppImage(p);
         File appDir = null;
 
@@ -374,7 +374,7 @@
                 try {
                     IOUtils.copyFile(icon, faIconFile);
                 } catch (IOException e) {
-                    e.printStackTrace();
+                    Log.verbose(e);
                 }
             }
         }
@@ -382,16 +382,15 @@
         return true;
     }
 
-    public File bundle(Map<String, ? super Object> p, File outdir) {
+    public File bundle(Map<String, ? super Object> p, File outdir)
+            throws PackagerException {
         if (!outdir.isDirectory() && !outdir.mkdirs()) {
-            throw new RuntimeException(MessageFormat.format(
-                    getString("error.cannot-create-output-dir"),
-                    outdir.getAbsolutePath()));
+            throw new PackagerException("error.cannot-create-output-dir",
+                    outdir.getAbsolutePath());
         }
         if (!outdir.canWrite()) {
-            throw new RuntimeException(MessageFormat.format(
-                    getString("error.cannot-write-to-output-dir"),
-                    outdir.getAbsolutePath()));
+            throw new PackagerException("error.cannot-write-to-output-dir",
+                    outdir.getAbsolutePath());
         }
 
         if (WindowsDefender.isThereAPotentialWindowsDefenderIssue()) {
@@ -403,10 +402,10 @@
         // validate we have valid tools before continuing
         String iscc = TOOL_INNO_SETUP_COMPILER_EXECUTABLE.fetchFrom(p);
         if (iscc == null || !new File(iscc).isFile()) {
-            Log.error(getString("error.iscc-not-found"));
-            Log.error(MessageFormat.format(
+            Log.verbose(getString("error.iscc-not-found"));
+            Log.verbose(MessageFormat.format(
                     getString("message.iscc-file-string"), iscc));
-            return null;
+            throw new PackagerException("error.iscc-not-found");
         }
 
         File imageDir = EXE_IMAGE_DIR.fetchFrom(p);
@@ -433,8 +432,8 @@
             }
             return null;
         } catch (IOException ex) {
-            ex.printStackTrace();
-            return null;
+            Log.verbose(ex);
+            throw new PackagerException(ex);
         }
     }
 
--- a/src/jdk.jpackage/windows/classes/jdk/jpackage/internal/WinMsiBundler.java	Wed Jan 30 19:48:18 2019 -0500
+++ b/src/jdk.jpackage/windows/classes/jdk/jpackage/internal/WinMsiBundler.java	Sun Feb 03 08:16:08 2019 -0500
@@ -233,8 +233,8 @@
     }
 
     @Override
-    public File execute(
-            Map<String, ? super Object> params, File outputParentDir) {
+    public File execute(Map<String, ? super Object> params,
+            File outputParentDir) throws PackagerException {
         return bundle(params, outputParentDir);
     }
 
@@ -424,7 +424,7 @@
     }
 
     private boolean prepareProto(Map<String, ? super Object> p)
-                throws IOException {
+                throws PackagerException, IOException {
         File appImage = StandardBundlerParam.getPredefinedAppImage(p);
         File appDir = null;
 
@@ -465,7 +465,7 @@
                 try {
                     IOUtils.copyFile(icon, faIconFile);
                 } catch (IOException e) {
-                    e.printStackTrace();
+                    Log.verbose(e);
                 }
             }
         }
@@ -473,16 +473,15 @@
         return appDir != null;
     }
 
-    public File bundle(Map<String, ? super Object> p, File outdir) {
+    public File bundle(Map<String, ? super Object> p, File outdir)
+            throws PackagerException {
         if (!outdir.isDirectory() && !outdir.mkdirs()) {
-            throw new RuntimeException(MessageFormat.format(
-                    I18N.getString("error.cannot-create-output-dir"),
-                    outdir.getAbsolutePath()));
+            throw new PackagerException("error.cannot-create-output-dir",
+                    outdir.getAbsolutePath());
         }
         if (!outdir.canWrite()) {
-            throw new RuntimeException(MessageFormat.format(
-                    I18N.getString("error.cannot-write-to-output-dir"),
-                    outdir.getAbsolutePath()));
+            throw new PackagerException("error.cannot-write-to-output-dir",
+                    outdir.getAbsolutePath());
         }
 
         // validate we have valid tools before continuing
@@ -490,12 +489,11 @@
         String candle = TOOL_CANDLE_EXECUTABLE.fetchFrom(p);
         if (light == null || !new File(light).isFile() ||
             candle == null || !new File(candle).isFile()) {
-            Log.error(I18N.getString("error.no-wix-tools"));
             Log.verbose(MessageFormat.format(
                    I18N.getString("message.light-file-string"), light));
             Log.verbose(MessageFormat.format(
                    I18N.getString("message.candle-file-string"), candle));
-            return null;
+            throw new PackagerException("error.no-wix-tools");
         }
 
         File imageDir = MSI_IMAGE_DIR.fetchFrom(p);
@@ -534,7 +532,7 @@
             return null;
         } catch (IOException ex) {
             Log.verbose(ex);
-            return null;
+            throw new PackagerException(ex);
         }
     }
 
--- a/test/jdk/tools/jpackage/JPackageInvalidArgTest.java	Wed Jan 30 19:48:18 2019 -0500
+++ b/test/jdk/tools/jpackage/JPackageInvalidArgTest.java	Sun Feb 03 08:16:08 2019 -0500
@@ -32,40 +32,47 @@
  */
 public class JPackageInvalidArgTest {
 
-    private static final String ARG = "--no-such-argument";
+    private static final String ARG1 = "--no-such-argument";
+    private static final String ARG2 = "--force";
     private static final String RESULT1 =
-            "invalid option [--no-such-argument]";
-    private static final String RESULT2 = "ERROR: Mode is not specified";
+            "Invalid Option: [--no-such-argument]";
+    private static final String RESULT2 = "Mode is not specified";
 
-    private static void validate(String output) throws Exception {
+    private static void validate(String arg, String output) throws Exception {
         String[] result = output.split("\n");
-        if (result.length != 2) {
+        if (result.length != 1) {
             System.err.println(output);
             throw new AssertionError("Invalid number of lines in output: "
                     + result.length);
         }
 
-        if (!result[0].trim().equals(RESULT1)) {
-            System.err.println("Expected: " + RESULT1);
-            System.err.println("Actual: " + result[0]);
-            throw new AssertionError("Unexpected line 1");
-        }
-
-        if (!result[1].trim().equals(RESULT2)) {
-            System.err.println("Expected: " + RESULT2);
-            System.err.println("Actual: " + result[1]);
-            throw new AssertionError("Unexpected line 2");
+        if (arg.equals(ARG1)) {
+            if (!result[0].trim().contains(RESULT1)) {
+                System.err.println("Expected: " + RESULT1);
+                System.err.println("Actual: " + result[0]);
+                throw new AssertionError("Unexpected output: " + result[0]);
+            }
+        } else if (arg.equals(ARG2)) {
+            if (!result[0].trim().contains(RESULT2)) {
+                System.err.println("Expected: " + RESULT2);
+                System.err.println("Actual: " + result[0]);
+                throw new AssertionError("Unexpected output: " + result[0]);
+            }
         }
     }
 
     private static void testInvalidArg() throws Exception {
-        String output = JPackageHelper.executeCLI(false, ARG);
-        validate(output);
+        String output = JPackageHelper.executeCLI(false, ARG1);
+        validate(ARG1, output);
+        output = JPackageHelper.executeCLI(false, ARG2);
+        validate(ARG2, output);
     }
 
     private static void testInvalidArgToolProvider() throws Exception {
-        String output = JPackageHelper.executeToolProvider(false, ARG);
-        validate(output);
+        String output = JPackageHelper.executeToolProvider(false, ARG1);
+        validate(ARG1, output);
+        output = JPackageHelper.executeToolProvider(false, ARG2);
+        validate(ARG2, output);
     }
 
     public static void main(String[] args) throws Exception {