exit codes: 0 = success; 4 = SQL error; 3 = other expected error; 1 = unexpected error (implicit 1) v_0
authorFrantišek Kučera <franta-hg@frantovo.cz>
Wed, 25 Dec 2013 01:03:28 +0100
branchv_0
changeset 5629f45ab3b959
parent 55 f5ed7c4efacc
child 57 a736c3917946
exit codes: 0 = success; 4 = SQL error; 3 = other expected error; 1 = unexpected error (implicit 1)
java/sql-dk/src/info/globalcode/sql/dk/CLIStarter.java
     1.1 --- a/java/sql-dk/src/info/globalcode/sql/dk/CLIStarter.java	Wed Dec 25 00:43:06 2013 +0100
     1.2 +++ b/java/sql-dk/src/info/globalcode/sql/dk/CLIStarter.java	Wed Dec 25 01:03:28 2013 +0100
     1.3 @@ -40,12 +40,16 @@
     1.4  public class CLIStarter implements ConfigurationProvider {
     1.5  
     1.6  	private static final Logger log = Logger.getLogger(CLIStarter.class.getName());
     1.7 +	private static final int EXIT_SUCCESS = 0;
     1.8 +	private static final int EXIT_EXPECTED_ERROR = 3;
     1.9 +	private static final int EXIT_SQL_ERROR = 4;
    1.10  	private CLIOptions options;
    1.11  	private Configuration configuration;
    1.12  
    1.13  	public static void main(String[] args) {
    1.14  		log.log(Level.FINE, "Starting " + Constants.PROGRAM_NAME);
    1.15 -
    1.16 +		int exitCode = EXIT_EXPECTED_ERROR;
    1.17 +		
    1.18  		if (args.length == 0) {
    1.19  			args = new String[]{CLIParser.Tokens.INFO_HELP};
    1.20  		}
    1.21 @@ -58,6 +62,7 @@
    1.22  			starter.installDefaultConfiguration();
    1.23  			starter.process();
    1.24  			log.log(Level.FINE, "All done");
    1.25 +			exitCode = EXIT_SUCCESS;
    1.26  		} catch (CLIParserException e) {
    1.27  			log.log(Level.SEVERE, "Unable to parse CLI options", e);
    1.28  		} catch (InvalidOptionsException e) {
    1.29 @@ -69,9 +74,12 @@
    1.30  			log.log(Level.SEVERE, "Configuration problem", e);
    1.31  		} catch (SQLException e) {
    1.32  			log.log(Level.SEVERE, "SQL problem", e);
    1.33 +			exitCode = EXIT_SQL_ERROR;
    1.34  		} catch (FormatterException e) {
    1.35  			log.log(Level.SEVERE, "Formatting problem", e);
    1.36  		}
    1.37 +
    1.38 +		System.exit(exitCode);
    1.39  	}
    1.40  
    1.41  	public CLIStarter(CLIOptions options) {