java/sql-dk/src/info/globalcode/sql/dk/CLIStarter.java
branchv_0
changeset 56 29f45ab3b959
parent 55 f5ed7c4efacc
child 63 3b9ec9c23a37
--- a/java/sql-dk/src/info/globalcode/sql/dk/CLIStarter.java	Wed Dec 25 00:43:06 2013 +0100
+++ b/java/sql-dk/src/info/globalcode/sql/dk/CLIStarter.java	Wed Dec 25 01:03:28 2013 +0100
@@ -40,12 +40,16 @@
 public class CLIStarter implements ConfigurationProvider {
 
 	private static final Logger log = Logger.getLogger(CLIStarter.class.getName());
+	private static final int EXIT_SUCCESS = 0;
+	private static final int EXIT_EXPECTED_ERROR = 3;
+	private static final int EXIT_SQL_ERROR = 4;
 	private CLIOptions options;
 	private Configuration configuration;
 
 	public static void main(String[] args) {
 		log.log(Level.FINE, "Starting " + Constants.PROGRAM_NAME);
-
+		int exitCode = EXIT_EXPECTED_ERROR;
+		
 		if (args.length == 0) {
 			args = new String[]{CLIParser.Tokens.INFO_HELP};
 		}
@@ -58,6 +62,7 @@
 			starter.installDefaultConfiguration();
 			starter.process();
 			log.log(Level.FINE, "All done");
+			exitCode = EXIT_SUCCESS;
 		} catch (CLIParserException e) {
 			log.log(Level.SEVERE, "Unable to parse CLI options", e);
 		} catch (InvalidOptionsException e) {
@@ -69,9 +74,12 @@
 			log.log(Level.SEVERE, "Configuration problem", e);
 		} catch (SQLException e) {
 			log.log(Level.SEVERE, "SQL problem", e);
+			exitCode = EXIT_SQL_ERROR;
 		} catch (FormatterException e) {
 			log.log(Level.SEVERE, "Formatting problem", e);
 		}
+
+		System.exit(exitCode);
 	}
 
 	public CLIStarter(CLIOptions options) {