java/sql-dk/src/info/globalcode/sql/dk/CLIParser.java
branchv_0
changeset 9 2ec52027b97f
parent 8 4507cb9a0cf1
child 10 f528406f33f4
     1.1 --- a/java/sql-dk/src/info/globalcode/sql/dk/CLIParser.java	Sun Dec 15 23:54:51 2013 +0100
     1.2 +++ b/java/sql-dk/src/info/globalcode/sql/dk/CLIParser.java	Sun Dec 15 23:58:58 2013 +0100
     1.3 @@ -27,7 +27,7 @@
     1.4  		types = Collections.unmodifiableMap(m);
     1.5  	}
     1.6  
     1.7 -	public CLIOptions parseOptions(String[] args) {
     1.8 +	public CLIOptions parseOptions(String[] args) throws CLIParserException {
     1.9  		CLIOptions options = new CLIOptions();
    1.10  
    1.11  		List<Integer> numberedTypes = new ArrayList<>();
    1.12 @@ -86,9 +86,9 @@
    1.13  								try {
    1.14  									paramType = numberedTypes.get(paramIndex);
    1.15  								} catch (IndexOutOfBoundsException e) {
    1.16 -									throw new IllegalArgumentException("Missing type for parameter #" + paramIndex, e);
    1.17 +									throw new CLIParserException("Missing type for parameter #" + paramIndex, e);
    1.18  								} catch (NullPointerException e) {
    1.19 -									throw new IllegalArgumentException("Invalid type definition for parameter #" + paramIndex, e);
    1.20 +									throw new CLIParserException("Invalid type definition for parameter #" + paramIndex, e);
    1.21  								}
    1.22  								parameter = new Parameter(arg, paramType);
    1.23  							}
    1.24 @@ -97,17 +97,17 @@
    1.25  					}
    1.26  					break;
    1.27  				default:
    1.28 -					throw new IllegalArgumentException("Unknown option: " + arg);
    1.29 +					throw new CLIParserException("Unknown option: " + arg);
    1.30  			}
    1.31  		}
    1.32  		return options;
    1.33  	}
    1.34  
    1.35 -	private String fetchNext(String[] args, int index) {
    1.36 +	private String fetchNext(String[] args, int index) throws CLIParserException {
    1.37  		if (index < args.length) {
    1.38  			return args[index];
    1.39  		} else {
    1.40 -			throw new IllegalArgumentException("Expecting value for option: " + args[index - 1]);
    1.41 +			throw new CLIParserException("Expecting value for option: " + args[index - 1]);
    1.42  		}
    1.43  	}
    1.44  
    1.45 @@ -126,10 +126,10 @@
    1.46  		}
    1.47  	}
    1.48  
    1.49 -	private int getType(String typeString) {
    1.50 +	private int getType(String typeString) throws CLIParserException {
    1.51  		Integer type = types.get(typeString);
    1.52  		if (type == null) {
    1.53 -			throw new IllegalArgumentException("Unsupported type: " + typeString);
    1.54 +			throw new CLIParserException("Unsupported type: " + typeString);
    1.55  		} else {
    1.56  			return type;
    1.57  		}