1.1 --- a/java/sql-dk/src/info/globalcode/sql/dk/CLIStarter.java Sat Dec 28 23:08:06 2013 +0100
1.2 +++ b/java/sql-dk/src/info/globalcode/sql/dk/CLIStarter.java Sun Dec 29 14:50:10 2013 +0100
1.3 @@ -46,16 +46,20 @@
1.4 */
1.5 public class CLIStarter implements ConfigurationProvider {
1.6
1.7 + public static final int EXIT_SUCCESS = 0; // doc:success
1.8 + public static final int EXIT_UNEXPECTED_ERROR = 1; // doc:unexpected error (probably bug)
1.9 + public static final int EXIT_SQL_ERROR = 3; // doc:SQL error
1.10 + public static final int EXIT_CLI_PARSE_ERROR = 4; // doc:CLI options parse error
1.11 + public static final int EXIT_CLI_VALIDATE_ERROR = 5; // doc:CLI options validation error
1.12 + public static final int EXIT_CONFIGURATION_ERROR = 6; // doc:configuration error
1.13 + public static final int EXIT_FORMATTING_ERROR = 7; // doc:formatting error
1.14 private static final Logger log = Logger.getLogger(CLIStarter.class.getName());
1.15 - private static final int EXIT_SUCCESS = 0;
1.16 - private static final int EXIT_EXPECTED_ERROR = 3;
1.17 - private static final int EXIT_SQL_ERROR = 4;
1.18 private CLIOptions options;
1.19 private Configuration configuration;
1.20
1.21 public static void main(String[] args) {
1.22 log.log(Level.FINE, "Starting " + Constants.PROGRAM_NAME);
1.23 - int exitCode = EXIT_EXPECTED_ERROR;
1.24 + int exitCode;
1.25
1.26 if (args.length == 0) {
1.27 args = new String[]{CLIParser.Tokens.INFO_HELP};
1.28 @@ -72,6 +76,7 @@
1.29 exitCode = EXIT_SUCCESS;
1.30 } catch (CLIParserException e) {
1.31 log.log(Level.SEVERE, "Unable to parse CLI options", e);
1.32 + exitCode = EXIT_CLI_PARSE_ERROR;
1.33 } catch (InvalidOptionsException e) {
1.34 log.log(Level.SEVERE, "Invalid CLI options", e);
1.35 for (InvalidOptionsException.OptionProblem p : e.getProblems()) {
1.36 @@ -80,13 +85,16 @@
1.37 r.setParameters(new Object[]{p.getDescription()});
1.38 log.log(r);
1.39 }
1.40 + exitCode = EXIT_CLI_VALIDATE_ERROR;
1.41 } catch (ConfigurationException e) {
1.42 log.log(Level.SEVERE, "Configuration problem", e);
1.43 + exitCode = EXIT_CONFIGURATION_ERROR;
1.44 } catch (SQLException e) {
1.45 log.log(Level.SEVERE, "SQL problem", e);
1.46 exitCode = EXIT_SQL_ERROR;
1.47 } catch (FormatterException e) {
1.48 log.log(Level.SEVERE, "Formatting problem", e);
1.49 + exitCode = EXIT_FORMATTING_ERROR;
1.50 }
1.51
1.52 System.exit(exitCode);