--- a/java/sql-dk/src/info/globalcode/sql/dk/CLIParser.java Sun Dec 15 23:54:51 2013 +0100
+++ b/java/sql-dk/src/info/globalcode/sql/dk/CLIParser.java Sun Dec 15 23:58:58 2013 +0100
@@ -27,7 +27,7 @@
types = Collections.unmodifiableMap(m);
}
- public CLIOptions parseOptions(String[] args) {
+ public CLIOptions parseOptions(String[] args) throws CLIParserException {
CLIOptions options = new CLIOptions();
List<Integer> numberedTypes = new ArrayList<>();
@@ -86,9 +86,9 @@
try {
paramType = numberedTypes.get(paramIndex);
} catch (IndexOutOfBoundsException e) {
- throw new IllegalArgumentException("Missing type for parameter #" + paramIndex, e);
+ throw new CLIParserException("Missing type for parameter #" + paramIndex, e);
} catch (NullPointerException e) {
- throw new IllegalArgumentException("Invalid type definition for parameter #" + paramIndex, e);
+ throw new CLIParserException("Invalid type definition for parameter #" + paramIndex, e);
}
parameter = new Parameter(arg, paramType);
}
@@ -97,17 +97,17 @@
}
break;
default:
- throw new IllegalArgumentException("Unknown option: " + arg);
+ throw new CLIParserException("Unknown option: " + arg);
}
}
return options;
}
- private String fetchNext(String[] args, int index) {
+ private String fetchNext(String[] args, int index) throws CLIParserException {
if (index < args.length) {
return args[index];
} else {
- throw new IllegalArgumentException("Expecting value for option: " + args[index - 1]);
+ throw new CLIParserException("Expecting value for option: " + args[index - 1]);
}
}
@@ -126,10 +126,10 @@
}
}
- private int getType(String typeString) {
+ private int getType(String typeString) throws CLIParserException {
Integer type = types.get(typeString);
if (type == null) {
- throw new IllegalArgumentException("Unsupported type: " + typeString);
+ throw new CLIParserException("Unsupported type: " + typeString);
} else {
return type;
}