# HG changeset patch
# User František Kučera <franta-hg@frantovo.cz>
# Date 1388001161 -3600
# Node ID deba1f6600f8ee73489e13d95c26ba60edac656e
# Parent  d4e88172a36369bc23ad2707e30f7345d513af00
expect invalid regexp in prefix/suffix and throw wrapped exception → better exit code

diff -r d4e88172a363 -r deba1f6600f8 java/sql-dk/src/info/globalcode/sql/dk/SQLCommandNamed.java
--- a/java/sql-dk/src/info/globalcode/sql/dk/SQLCommandNamed.java	Wed Dec 25 16:38:05 2013 +0100
+++ b/java/sql-dk/src/info/globalcode/sql/dk/SQLCommandNamed.java	Wed Dec 25 20:52:41 2013 +0100
@@ -28,6 +28,7 @@
 import java.util.logging.Logger;
 import java.util.regex.Matcher;
 import java.util.regex.Pattern;
+import java.util.regex.PatternSyntaxException;
 
 /**
  *
@@ -53,9 +54,13 @@
 
 	@Override
 	public PreparedStatement prepareStatement(Connection c) throws SQLException {
-		buildPattern();
-		placeParametersAndUpdateQuery();
-		logPossiblyMissingParameters();
+		try {
+			buildPattern();
+			placeParametersAndUpdateQuery();
+			logPossiblyMissingParameters();
+		} catch (PatternSyntaxException e) {
+			throw new SQLException("Name prefix „" + namePrefix + "“ or suffix „" + nameSuffix + "“ contain a wrong regular expression. " + e.getLocalizedMessage(), e);
+		}
 		return c.prepareStatement(updatedQuery.toString());
 	}