diff --git a/src/main/java/sqlline/SqlLineOpts.java b/src/main/java/sqlline/SqlLineOpts.java index 8c742f1b..adb1b1ba 100644 --- a/src/main/java/sqlline/SqlLineOpts.java +++ b/src/main/java/sqlline/SqlLineOpts.java @@ -342,8 +342,13 @@ public void set(SqlLineProperty key, Object value) { valueToSet = value instanceof Integer || value.getClass() == int.class ? value : Integer.parseInt(String.valueOf(value)); } catch (Exception e) { - sqlLine.error(sqlLine.loc("not-a-number")); - sqlLine.handleException(e); + sqlLine.error( + sqlLine.loc("not-a-number", + key.propertyName().toLowerCase(Locale.ROOT), + value)); + if (getVerbose()) { + sqlLine.handleException(e); + } return; } break; diff --git a/src/main/resources/sqlline/SqlLine.properties b/src/main/resources/sqlline/SqlLine.properties index 0546fa60..29186ff8 100644 --- a/src/main/resources/sqlline/SqlLine.properties +++ b/src/main/resources/sqlline/SqlLine.properties @@ -23,7 +23,7 @@ no-specified-prop: Specified property [{0}] does not exist. \ Use !set command to get list of all available properties. reset-all-props: All properties were reset to their defaults. reset-prop: [{0}] was reset to [{1}] -not-a-number: "Value should be a number" +not-a-number: Value for property {0} should be a number. Specified value is: {1}. jdbc-level: JDBC level compliant: Compliant diff --git a/src/test/java/sqlline/PromptTest.java b/src/test/java/sqlline/PromptTest.java index 6da5e8f6..936fade2 100644 --- a/src/test/java/sqlline/PromptTest.java +++ b/src/test/java/sqlline/PromptTest.java @@ -120,7 +120,7 @@ public void testPromptWithNickname() { ByteArrayOutputStream os = new ByteArrayOutputStream(); SqlLine sqlLine = new SqlLine(); try { - SqlLine.Status status = + final SqlLine.Status status = begin(sqlLine, os, false, "-e", "!set maxwidth 80"); assertThat(status, equalTo(SqlLine.Status.OK)); final DispatchCallback dc = new DispatchCallback(); @@ -149,7 +149,7 @@ public void testPromptWithConnection() { ByteArrayOutputStream os = new ByteArrayOutputStream(); SqlLine sqlLine = new SqlLine(); try { - SqlLine.Status status = + final SqlLine.Status status = begin(sqlLine, os, false, "-e", "!set maxwidth 80"); assertThat(status, equalTo(SqlLine.Status.OK)); final DispatchCallback dc = new DispatchCallback(); diff --git a/src/test/java/sqlline/SqlLineArgsTest.java b/src/test/java/sqlline/SqlLineArgsTest.java index f0295328..08233eda 100644 --- a/src/test/java/sqlline/SqlLineArgsTest.java +++ b/src/test/java/sqlline/SqlLineArgsTest.java @@ -62,8 +62,8 @@ public SqlLineArgsTest() { connectionSpec = CONNECTION_SPEC; } - static SqlLine.Status begin( - SqlLine sqlLine, OutputStream os, boolean saveHistory, String... args) { + static SqlLine.Status begin(SqlLine sqlLine, OutputStream os, + boolean saveHistory, String... args) { try { PrintStream beelineOutputStream = getPrintStream(os); sqlLine.setOutputStream(beelineOutputStream); @@ -509,9 +509,7 @@ public void testManual() { new MockUp() { @Mock void less(Terminal terminal, InputStream in, PrintStream out, - PrintStream err, - Path currentDir, - String[] argv) { + PrintStream err, Path currentDir, String[] argv) { } }; @@ -1092,11 +1090,11 @@ public void testSetNonIntValuesToIntProperties() { SqlLine sqlLine = new SqlLine(); final String headerIntervalScript = "!set headerinterval abc\n"; checkScriptFile(headerIntervalScript, false, equalTo(SqlLine.Status.OK), - containsString(sqlLine.loc("not-a-number"))); + containsString(sqlLine.loc("not-a-number", "headerinterval", "abc"))); final String rowLimitScript = "!set rowlimit xxx\n"; checkScriptFile(rowLimitScript, false, equalTo(SqlLine.Status.OK), - containsString(sqlLine.loc("not-a-number"))); + containsString(sqlLine.loc("not-a-number", "rowlimit", "xxx"))); } @Test