[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

[Pki-devel] [PATCH] 931 Cleaned up error handling in system, logging, and selftest CLIs.



The system, logging, and selftest CLIs have been modified to use
Exceptions instead of System.exit() such that errors can be
handled consistently.

Pushed to master under trivial rule.

--
Endi S. Dewata
>From c11e7f745f246426addb48c83ed9b25ff7933157 Mon Sep 17 00:00:00 2001
From: "Endi S. Dewata" <edewata redhat com>
Date: Wed, 18 Jan 2017 02:21:07 +0100
Subject: [PATCH] Cleaned up error handling in system, logging, and selftest
 CLIs.

The system, logging, and selftest CLIs have been modified to use
Exceptions instead of System.exit() such that errors can be
handled consistently.
---
 .../netscape/cmstools/logging/ActivityFindCLI.java | 14 ++----------
 .../netscape/cmstools/logging/ActivityShowCLI.java | 18 +++------------
 .../netscape/cmstools/logging/AuditModifyCLI.java  | 26 +++++-----------------
 .../netscape/cmstools/logging/AuditShowCLI.java    | 18 +++------------
 .../cmstools/selftests/SelfTestFindCLI.java        | 14 ++----------
 .../cmstools/selftests/SelfTestRunCLI.java         | 14 ++----------
 .../cmstools/selftests/SelfTestShowCLI.java        | 18 +++------------
 .../cmstools/system/KRAConnectorAddCLI.java        | 24 +++++---------------
 .../cmstools/system/KRAConnectorRemoveCLI.java     | 18 +++------------
 .../cmstools/system/KRAConnectorShowCLI.java       |  3 +--
 .../cmstools/system/SecurityDomainShowCLI.java     | 18 +++------------
 .../cmstools/system/TPSConnectorAddCLI.java        | 18 +++------------
 .../cmstools/system/TPSConnectorFindCLI.java       | 18 +++------------
 .../cmstools/system/TPSConnectorModCLI.java        | 18 +++------------
 .../cmstools/system/TPSConnectorRemoveCLI.java     | 18 +++------------
 .../cmstools/system/TPSConnectorShowCLI.java       | 18 +++------------
 16 files changed, 47 insertions(+), 228 deletions(-)

diff --git a/base/java-tools/src/com/netscape/cmstools/logging/ActivityFindCLI.java b/base/java-tools/src/com/netscape/cmstools/logging/ActivityFindCLI.java
index 413eae10155c9298c9c510ed186b451cb8843239..9e31795b4415fe34dc37a6e2f835c4a0a39b3d3e 100644
--- a/base/java-tools/src/com/netscape/cmstools/logging/ActivityFindCLI.java
+++ b/base/java-tools/src/com/netscape/cmstools/logging/ActivityFindCLI.java
@@ -60,21 +60,11 @@ public class ActivityFindCLI extends CLI {
     public void execute(String[] args) throws Exception {
         // Always check for "--help" prior to parsing
         if (Arrays.asList(args).contains("--help")) {
-            // Display usage
             printHelp();
-            System.exit(0);
+            return;
         }
 
-        CommandLine cmd = null;
-
-        try {
-            cmd = parser.parse(options, args);
-
-        } catch (Exception e) {
-            System.err.println("Error: " + e.getMessage());
-            printHelp();
-            System.exit(-1);
-        }
+        CommandLine cmd = parser.parse(options, args);
 
         String[] cmdArgs = cmd.getArgs();
         String filter = cmdArgs.length > 0 ? cmdArgs[0] : null;
diff --git a/base/java-tools/src/com/netscape/cmstools/logging/ActivityShowCLI.java b/base/java-tools/src/com/netscape/cmstools/logging/ActivityShowCLI.java
index b68d6adb547f891061d1de2731a0400dff859302..bae172c7912eb854ecdfb716cb1eafa67efdcfa3 100644
--- a/base/java-tools/src/com/netscape/cmstools/logging/ActivityShowCLI.java
+++ b/base/java-tools/src/com/netscape/cmstools/logging/ActivityShowCLI.java
@@ -45,28 +45,16 @@ public class ActivityShowCLI extends CLI {
     public void execute(String[] args) throws Exception {
         // Always check for "--help" prior to parsing
         if (Arrays.asList(args).contains("--help")) {
-            // Display usage
             printHelp();
-            System.exit(0);
+            return;
         }
 
-        CommandLine cmd = null;
-
-        try {
-            cmd = parser.parse(options, args);
-
-        } catch (Exception e) {
-            System.err.println("Error: " + e.getMessage());
-            printHelp();
-            System.exit(-1);
-        }
+        CommandLine cmd = parser.parse(options, args);
 
         String[] cmdArgs = cmd.getArgs();
 
         if (cmdArgs.length != 1) {
-            System.err.println("Error: No Activity ID specified.");
-            printHelp();
-            System.exit(-1);
+            throw new Exception("No Activity ID specified.");
         }
 
         String activityID = args[0];
diff --git a/base/java-tools/src/com/netscape/cmstools/logging/AuditModifyCLI.java b/base/java-tools/src/com/netscape/cmstools/logging/AuditModifyCLI.java
index ab9f821b3873787f7e46afa33f2ac94077b694dc..4dc5d8bdc0426dbd1a9ae5a298e573df8e5cfb4d 100644
--- a/base/java-tools/src/com/netscape/cmstools/logging/AuditModifyCLI.java
+++ b/base/java-tools/src/com/netscape/cmstools/logging/AuditModifyCLI.java
@@ -67,28 +67,16 @@ public class AuditModifyCLI extends CLI {
     public void execute(String[] args) throws Exception {
         // Always check for "--help" prior to parsing
         if (Arrays.asList(args).contains("--help")) {
-            // Display usage
             printHelp();
-            System.exit(0);
+            return;
         }
 
-        CommandLine cmd = null;
-
-        try {
-            cmd = parser.parse(options, args);
-
-        } catch (Exception e) {
-            System.err.println("Error: " + e.getMessage());
-            printHelp();
-            System.exit(-1);
-        }
+        CommandLine cmd = parser.parse(options, args);
 
         String[] cmdArgs = cmd.getArgs();
 
         if (cmdArgs.length != 0) {
-            System.err.println("Error: Too many arguments specified.");
-            printHelp();
-            System.exit(-1);
+            throw new Exception("Too many arguments specified.");
         }
 
         String action = cmd.getOptionValue("action");
@@ -100,9 +88,7 @@ public class AuditModifyCLI extends CLI {
         if (action == null) { // modify audit configuration
 
             if (input == null) {
-                System.err.println("Error: Missing action or input file.");
-                printHelp();
-                System.exit(-1);
+                throw new Exception("Missing action or input file.");
             }
 
             try (BufferedReader in = new BufferedReader(new FileReader(input));
@@ -122,9 +108,7 @@ public class AuditModifyCLI extends CLI {
         } else { // change audit status
 
             if (input != null) {
-                System.err.println("Error: Action and input file are mutually exclusive.");
-                printHelp();
-                System.exit(-1);
+                throw new Exception("Action and input file are mutually exclusive.");
             }
 
             auditConfig = auditCLI.auditClient.changeAuditStatus(action);
diff --git a/base/java-tools/src/com/netscape/cmstools/logging/AuditShowCLI.java b/base/java-tools/src/com/netscape/cmstools/logging/AuditShowCLI.java
index 34f708c721ec57b8a20b0613ddd35fa2af74dbff..c54055961c16acabcc1a14bf7c135b98b8050a4d 100644
--- a/base/java-tools/src/com/netscape/cmstools/logging/AuditShowCLI.java
+++ b/base/java-tools/src/com/netscape/cmstools/logging/AuditShowCLI.java
@@ -56,28 +56,16 @@ public class AuditShowCLI extends CLI {
     public void execute(String[] args) throws Exception {
         // Always check for "--help" prior to parsing
         if (Arrays.asList(args).contains("--help")) {
-            // Display usage
             printHelp();
-            System.exit(0);
+            return;
         }
 
-        CommandLine cmd = null;
-
-        try {
-            cmd = parser.parse(options, args);
-
-        } catch (Exception e) {
-            System.err.println("Error: " + e.getMessage());
-            printHelp();
-            System.exit(-1);
-        }
+        CommandLine cmd = parser.parse(options, args);
 
         String[] cmdArgs = cmd.getArgs();
 
         if (cmdArgs.length != 0) {
-            System.err.println("Error: Too many arguments specified.");
-            printHelp();
-            System.exit(-1);
+            throw new Exception("Too many arguments specified.");
         }
 
         String output = cmd.getOptionValue("output");
diff --git a/base/java-tools/src/com/netscape/cmstools/selftests/SelfTestFindCLI.java b/base/java-tools/src/com/netscape/cmstools/selftests/SelfTestFindCLI.java
index 2ac631dea434e31a9ff6005c9f9c5cff657a6a25..e98ab21d643321cdbf09214c8a2474361298c694 100644
--- a/base/java-tools/src/com/netscape/cmstools/selftests/SelfTestFindCLI.java
+++ b/base/java-tools/src/com/netscape/cmstools/selftests/SelfTestFindCLI.java
@@ -60,21 +60,11 @@ public class SelfTestFindCLI extends CLI {
     public void execute(String[] args) throws Exception {
         // Always check for "--help" prior to parsing
         if (Arrays.asList(args).contains("--help")) {
-            // Display usage
             printHelp();
-            System.exit(0);
+            return;
         }
 
-        CommandLine cmd = null;
-
-        try {
-            cmd = parser.parse(options, args);
-
-        } catch (Exception e) {
-            System.err.println("Error: " + e.getMessage());
-            printHelp();
-            System.exit(-1);
-        }
+        CommandLine cmd = parser.parse(options, args);
 
         String[] cmdArgs = cmd.getArgs();
         String filter = cmdArgs.length > 0 ? cmdArgs[0] : null;
diff --git a/base/java-tools/src/com/netscape/cmstools/selftests/SelfTestRunCLI.java b/base/java-tools/src/com/netscape/cmstools/selftests/SelfTestRunCLI.java
index 2e40ee4f885c3e48bf5d22847807517ddc626586..59f8a71a85cfb53c17f0337b2c7645302f3f33f8 100644
--- a/base/java-tools/src/com/netscape/cmstools/selftests/SelfTestRunCLI.java
+++ b/base/java-tools/src/com/netscape/cmstools/selftests/SelfTestRunCLI.java
@@ -60,21 +60,11 @@ public class SelfTestRunCLI extends CLI {
     public void execute(String[] args) throws Exception {
         // Always check for "--help" prior to parsing
         if (Arrays.asList(args).contains("--help")) {
-            // Display usage
             printHelp();
-            System.exit(0);
+            return;
         }
 
-        CommandLine cmd = null;
-
-        try {
-            cmd = parser.parse(options, args);
-
-        } catch (Exception e) {
-            System.err.println("Error: " + e.getMessage());
-            printHelp();
-            System.exit(-1);
-        }
+        CommandLine cmd = parser.parse(options, args);
 
         String[] cmdArgs = cmd.getArgs();
 
diff --git a/base/java-tools/src/com/netscape/cmstools/selftests/SelfTestShowCLI.java b/base/java-tools/src/com/netscape/cmstools/selftests/SelfTestShowCLI.java
index 56ff88954ace5a5aae5c128f975f2cfd221d1e9f..cce4fb58766c3df32b53557c795cd8bbaae4ba15 100644
--- a/base/java-tools/src/com/netscape/cmstools/selftests/SelfTestShowCLI.java
+++ b/base/java-tools/src/com/netscape/cmstools/selftests/SelfTestShowCLI.java
@@ -56,28 +56,16 @@ public class SelfTestShowCLI extends CLI {
     public void execute(String[] args) throws Exception {
         // Always check for "--help" prior to parsing
         if (Arrays.asList(args).contains("--help")) {
-            // Display usage
             printHelp();
-            System.exit(0);
+            return;
         }
 
-        CommandLine cmd = null;
-
-        try {
-            cmd = parser.parse(options, args);
-
-        } catch (Exception e) {
-            System.err.println("Error: " + e.getMessage());
-            printHelp();
-            System.exit(-1);
-        }
+        CommandLine cmd = parser.parse(options, args);
 
         String[] cmdArgs = cmd.getArgs();
 
         if (cmdArgs.length != 1) {
-            System.err.println("Error: No SelfTest ID specified.");
-            printHelp();
-            System.exit(-1);
+            throw new Exception("No SelfTest ID specified.");
         }
 
         String selfTestID = args[0];
diff --git a/base/java-tools/src/com/netscape/cmstools/system/KRAConnectorAddCLI.java b/base/java-tools/src/com/netscape/cmstools/system/KRAConnectorAddCLI.java
index 7327c40dec770f48e790fe4efae62bf8cef921f9..1cf7546ab938f89b7ba4b16a061514db421e29b8 100644
--- a/base/java-tools/src/com/netscape/cmstools/system/KRAConnectorAddCLI.java
+++ b/base/java-tools/src/com/netscape/cmstools/system/KRAConnectorAddCLI.java
@@ -25,7 +25,6 @@ import javax.xml.bind.Unmarshaller;
 
 import org.apache.commons.cli.CommandLine;
 import org.apache.commons.cli.Option;
-import org.apache.commons.cli.ParseException;
 
 import com.netscape.certsrv.system.ConnectorNotFoundException;
 import com.netscape.certsrv.system.KRAConnectorInfo;
@@ -68,27 +67,16 @@ public class KRAConnectorAddCLI extends CLI {
     public void execute(String[] args) throws Exception {
         // Always check for "--help" prior to parsing
         if (Arrays.asList(args).contains("--help")) {
-            // Display usage
             printHelp();
-            System.exit(0);
+            return;
         }
 
-        CommandLine cmd = null;
-
-        try {
-            cmd = parser.parse(options, args);
-        } catch (ParseException e) {
-            System.err.println("Error: " + e.getMessage());
-            printHelp();
-            System.exit(-1);
-        }
+        CommandLine cmd = parser.parse(options, args);
 
         String[] cmdArgs = cmd.getArgs();
 
         if (cmdArgs.length != 0) {
-            System.err.println("Error: Too many arguments specified.");
-            printHelp();
-            System.exit(-1);
+            throw new Exception("Too many arguments specified.");
         }
 
         String kraHost = cmd.getOptionValue("host");
@@ -106,9 +94,8 @@ public class KRAConnectorAddCLI extends CLI {
 
         if (inputFile != null) {
             if (connectorExists) {
-                System.err.println("Error: Cannot add new connector from file.  " +
+                throw new Exception("Cannot add new connector from file.  " +
                         "Delete the existing connector first");
-                System.exit(-1);
             }
             FileInputStream fis = new FileInputStream(inputFile);
             JAXBContext context = JAXBContext.newInstance(KRAConnectorInfo.class);
@@ -120,9 +107,8 @@ public class KRAConnectorAddCLI extends CLI {
 
         } else {
             if (!connectorExists) {
-                System.err.println("Error: Cannot add new host to existing connector.  " +
+                throw new Exception("Cannot add new host to existing connector.  " +
                         "No connector currently exists");
-                System.exit(-1);
             }
             kraConnectorCLI.kraConnectorClient.addHost(kraHost, kraPort);
             MainCLI.printMessage("Added KRA host \"" + kraHost + ":" + kraPort + "\"");
diff --git a/base/java-tools/src/com/netscape/cmstools/system/KRAConnectorRemoveCLI.java b/base/java-tools/src/com/netscape/cmstools/system/KRAConnectorRemoveCLI.java
index 562ee542a8b2915ed1b1cf9f809c8f96d5e7e1fd..37383a62a2dab80c47bbd3de166b7701120772f2 100644
--- a/base/java-tools/src/com/netscape/cmstools/system/KRAConnectorRemoveCLI.java
+++ b/base/java-tools/src/com/netscape/cmstools/system/KRAConnectorRemoveCLI.java
@@ -56,28 +56,16 @@ public class KRAConnectorRemoveCLI extends CLI {
     public void execute(String[] args) throws Exception {
         // Always check for "--help" prior to parsing
         if (Arrays.asList(args).contains("--help")) {
-            // Display usage
             printHelp();
-            System.exit(0);
+            return;
         }
 
-        CommandLine cmd = null;
-
-        try {
-            cmd = parser.parse(options, args);
-
-        } catch (Exception e) {
-            System.err.println("Error: " + e.getMessage());
-            printHelp();
-            System.exit(-1);
-        }
+        CommandLine cmd = parser.parse(options, args);
 
         String[] cmdArgs = cmd.getArgs();
 
         if (cmdArgs.length != 0) {
-            System.err.println("Error: Incorrect number of arguments specified.");
-            printHelp();
-            System.exit(-1);
+            throw new Exception("Incorrect number of arguments specified.");
         }
 
         String kraHost = cmd.getOptionValue("host");
diff --git a/base/java-tools/src/com/netscape/cmstools/system/KRAConnectorShowCLI.java b/base/java-tools/src/com/netscape/cmstools/system/KRAConnectorShowCLI.java
index 4e3498b94c8747c95ef44f6ed9c10b441c1652dc..c5aa3262cb27e0612d79b0ae875f76560a2da45d 100644
--- a/base/java-tools/src/com/netscape/cmstools/system/KRAConnectorShowCLI.java
+++ b/base/java-tools/src/com/netscape/cmstools/system/KRAConnectorShowCLI.java
@@ -21,9 +21,8 @@ public class KRAConnectorShowCLI extends CLI {
     public void execute(String[] args) {
         // Always check for "--help" prior to parsing
         if (Arrays.asList(args).contains("--help")) {
-            // Display usage
             printHelp();
-            System.exit(0);
+            return;
         }
 
         KRAConnectorInfo info = kraConnectorCLI.kraConnectorClient.getConnectorInfo();
diff --git a/base/java-tools/src/com/netscape/cmstools/system/SecurityDomainShowCLI.java b/base/java-tools/src/com/netscape/cmstools/system/SecurityDomainShowCLI.java
index dd6c92033025f5b08c238fef896c83325d4e4c9e..14d8e6685c502859ef62ced0ccaeb524894ff382 100644
--- a/base/java-tools/src/com/netscape/cmstools/system/SecurityDomainShowCLI.java
+++ b/base/java-tools/src/com/netscape/cmstools/system/SecurityDomainShowCLI.java
@@ -44,28 +44,16 @@ public class SecurityDomainShowCLI extends CLI {
     public void execute(String[] args) throws Exception {
         // Always check for "--help" prior to parsing
         if (Arrays.asList(args).contains("--help")) {
-            // Display usage
             printHelp();
-            System.exit(0);
+            return;
         }
 
-        CommandLine cmd = null;
-
-        try {
-            cmd = parser.parse(options, args);
-
-        } catch (Exception e) {
-            System.err.println("Error: " + e.getMessage());
-            printHelp();
-            System.exit(-1);
-        }
+        CommandLine cmd = parser.parse(options, args);
 
         String[] cmdArgs = cmd.getArgs();
 
         if (cmdArgs.length != 0) {
-            System.err.println("Error: Too many arguments specified.");
-            printHelp();
-            System.exit(-1);
+            throw new Exception("Too many arguments specified.");
         }
 
         DomainInfo domain = securityDomainCLI.securityDomainClient.getDomainInfo();
diff --git a/base/java-tools/src/com/netscape/cmstools/system/TPSConnectorAddCLI.java b/base/java-tools/src/com/netscape/cmstools/system/TPSConnectorAddCLI.java
index ceeccdfefc233437ed484afa9536964d03cb6423..82409723b8452362219209442b3f4cc4aca51bff 100644
--- a/base/java-tools/src/com/netscape/cmstools/system/TPSConnectorAddCLI.java
+++ b/base/java-tools/src/com/netscape/cmstools/system/TPSConnectorAddCLI.java
@@ -55,28 +55,16 @@ public class TPSConnectorAddCLI extends CLI {
     public void execute(String[] args) throws Exception {
         // Always check for "--help" prior to parsing
         if (Arrays.asList(args).contains("--help")) {
-            // Display usage
             printHelp();
-            System.exit(0);
+            return;
         }
 
-        CommandLine cmd = null;
-
-        try {
-            cmd = parser.parse(options, args);
-
-        } catch (Exception e) {
-            System.err.println("Error: " + e.getMessage());
-            printHelp();
-            System.exit(-1);
-        }
+        CommandLine cmd = parser.parse(options, args);
 
         String[] cmdArgs = cmd.getArgs();
 
         if (cmdArgs.length != 0) {
-            System.err.println("Error: Too many arguments specified.");
-            printHelp();
-            System.exit(-1);
+            throw new Exception("Too many arguments specified.");
         }
 
         String tpsHost = cmd.getOptionValue("host");
diff --git a/base/java-tools/src/com/netscape/cmstools/system/TPSConnectorFindCLI.java b/base/java-tools/src/com/netscape/cmstools/system/TPSConnectorFindCLI.java
index bdff05624e6e2741c36ff21a866c90def1c50b43..d52c3441254da3d28f9ec00e26d80d9d999dd322 100644
--- a/base/java-tools/src/com/netscape/cmstools/system/TPSConnectorFindCLI.java
+++ b/base/java-tools/src/com/netscape/cmstools/system/TPSConnectorFindCLI.java
@@ -59,28 +59,16 @@ public class TPSConnectorFindCLI extends CLI {
     public void execute(String[] args) throws Exception {
         // Always check for "--help" prior to parsing
         if (Arrays.asList(args).contains("--help")) {
-            // Display usage
             printHelp();
-            System.exit(0);
+            return;
         }
 
-        CommandLine cmd = null;
-
-        try {
-            cmd = parser.parse(options, args);
-
-        } catch (Exception e) {
-            System.err.println("Error: " + e.getMessage());
-            printHelp();
-            System.exit(-1);
-        }
+        CommandLine cmd = parser.parse(options, args);
 
         String[] cmdArgs = cmd.getArgs();
 
         if (cmdArgs.length != 0) {
-            System.err.println("Error: Too many arguments specified.");
-            printHelp();
-            System.exit(-1);
+            throw new Exception("Too many arguments specified.");
         }
 
         String s = cmd.getOptionValue("start");
diff --git a/base/java-tools/src/com/netscape/cmstools/system/TPSConnectorModCLI.java b/base/java-tools/src/com/netscape/cmstools/system/TPSConnectorModCLI.java
index f9de2ab985b5dc492c5efd6951410abeb1fd6d73..2bc2a644f85b77c3170fc50c459f02745cfa7c20 100644
--- a/base/java-tools/src/com/netscape/cmstools/system/TPSConnectorModCLI.java
+++ b/base/java-tools/src/com/netscape/cmstools/system/TPSConnectorModCLI.java
@@ -36,28 +36,16 @@ public class TPSConnectorModCLI extends CLI {
     public void execute(String[] args) throws Exception {
         // Always check for "--help" prior to parsing
         if (Arrays.asList(args).contains("--help")) {
-            // Display usage
             printHelp();
-            System.exit(0);
+            return;
         }
 
-        CommandLine cmd = null;
-
-        try {
-            cmd = parser.parse(options, args);
-
-        } catch (Exception e) {
-            System.err.println("Error: " + e.getMessage());
-            printHelp();
-            System.exit(-1);
-        }
+        CommandLine cmd = parser.parse(options, args);
 
         String[] cmdArgs = cmd.getArgs();
 
         if (cmdArgs.length != 1) {
-            System.err.println("Error: No Connector ID specified.");
-            printHelp();
-            System.exit(-1);
+            throw new Exception("No Connector ID specified.");
         }
 
         String connID = cmdArgs[0];
diff --git a/base/java-tools/src/com/netscape/cmstools/system/TPSConnectorRemoveCLI.java b/base/java-tools/src/com/netscape/cmstools/system/TPSConnectorRemoveCLI.java
index e8355de2ec0c4b6ac0a3d5b48a824623712051c1..96432cf3b914c7ea86884a8a3be3872d6760a847 100644
--- a/base/java-tools/src/com/netscape/cmstools/system/TPSConnectorRemoveCLI.java
+++ b/base/java-tools/src/com/netscape/cmstools/system/TPSConnectorRemoveCLI.java
@@ -55,28 +55,16 @@ public class TPSConnectorRemoveCLI extends CLI {
     public void execute(String[] args) throws Exception {
         // Always check for "--help" prior to parsing
         if (Arrays.asList(args).contains("--help")) {
-            // Display usage
             printHelp();
-            System.exit(0);
+            return;
         }
 
-        CommandLine cmd = null;
-
-        try {
-            cmd = parser.parse(options, args);
-
-        } catch (Exception e) {
-            System.err.println("Error: " + e.getMessage());
-            printHelp();
-            System.exit(-1);
-        }
+        CommandLine cmd = parser.parse(options, args);
 
         String[] cmdArgs = cmd.getArgs();
 
         if (cmdArgs.length != 0) {
-            System.err.println("Error: Too many arguments specified.");
-            printHelp();
-            System.exit(-1);
+            throw new Exception("Too many arguments specified.");
         }
 
         String tpsHost = cmd.getOptionValue("host");
diff --git a/base/java-tools/src/com/netscape/cmstools/system/TPSConnectorShowCLI.java b/base/java-tools/src/com/netscape/cmstools/system/TPSConnectorShowCLI.java
index 2c2cb182c9f318a52e3eec6ceee46a0f11e7b1c6..c0f09e4f07f6215b34764ff3a69ab4061fba4026 100644
--- a/base/java-tools/src/com/netscape/cmstools/system/TPSConnectorShowCLI.java
+++ b/base/java-tools/src/com/netscape/cmstools/system/TPSConnectorShowCLI.java
@@ -58,28 +58,16 @@ public class TPSConnectorShowCLI extends CLI {
     public void execute(String[] args) throws Exception {
         // Always check for "--help" prior to parsing
         if (Arrays.asList(args).contains("--help")) {
-            // Display usage
             printHelp();
-            System.exit(0);
+            return;
         }
 
-        CommandLine cmd = null;
-
-        try {
-            cmd = parser.parse(options, args);
-
-        } catch (Exception e) {
-            System.err.println("Error: " + e.getMessage());
-            printHelp();
-            System.exit(-1);
-        }
+        CommandLine cmd = parser.parse(options, args);
 
         String[] cmdArgs = cmd.getArgs();
 
         if (cmdArgs.length != 0) {
-            System.err.println("Error: Too many arguments specified.");
-            printHelp();
-            System.exit(-1);
+            throw new Exception("Too many arguments specified.");
         }
 
         String tpsHost = cmd.getOptionValue("host");
-- 
2.5.5


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]