Skip to content

Commit

Permalink
Removed System.exit and catch errors in run()
Browse files Browse the repository at this point in the history
  • Loading branch information
jshughes committed Dec 4, 2024
1 parent 819960e commit 75c985c
Showing 1 changed file with 13 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -343,9 +343,15 @@ public static void main(String[] args) throws Throwable {
*/
public static void run(String[] args) throws Throwable {
init();

// get the command line arguments using argparse4j
Namespace argparse4jNamespace = getArgumentParserNamespace(args);

// get the command line arguments using argparse4j
Namespace argparse4jNamespace = null;
try {
argparse4jNamespace = getArgumentParserNamespace(args);
} catch (Throwable e) {
return;
}

String nameSpaceDataDirPath = null;

// process first set of arguments
Expand Down Expand Up @@ -1142,7 +1148,7 @@ static void setRegistryAttrFlag() {
registryAttr.add("version_id");
}

static Namespace getArgumentParserNamespace(String args[]) throws ArgumentParserException {
static Namespace getArgumentParserNamespace(String args[]) throws Throwable {
parser = ArgumentParsers.newFor("LDDTool").build().defaultHelp(true).version(LDDToolVersionId)
.description("LDDTool process control:");

Expand Down Expand Up @@ -1226,14 +1232,13 @@ static Namespace getArgumentParserNamespace(String args[]) throws ArgumentParser
try {
namespace = parser.parseArgs(args);
} catch (HelpScreenException e) {
System.out.println(">> INFO Exit(0)");
// the library prints the help message internally so no need for parser.printHelp()
System.exit(0);
throw e;
} catch (ArgumentParserException e) {
System.out.println(">> ERROR Invalid argument list");
lMessageFatalErrorCount++;
parser.printHelp();
System.out.println(">> INFO Exit(1)");
System.exit(1);
throw e;
}
return namespace;
}
Expand Down

0 comments on commit 75c985c

Please sign in to comment.