Renamed exception classes: ConfigurationSettingValueException to 
InvalidSettingValueException, UnknownConfigurationSettingException to 
InvalidSettingNameException.


Project: http://git-wip-us.apache.org/repos/asf/incubator-freemarker/repo
Commit: 
http://git-wip-us.apache.org/repos/asf/incubator-freemarker/commit/c42014cc
Tree: http://git-wip-us.apache.org/repos/asf/incubator-freemarker/tree/c42014cc
Diff: http://git-wip-us.apache.org/repos/asf/incubator-freemarker/diff/c42014cc

Branch: refs/heads/3
Commit: c42014cc0042c4088ed986b8d72025e88846de37
Parents: 2e50994
Author: ddekany <[email protected]>
Authored: Thu Jun 8 08:04:33 2017 +0200
Committer: ddekany <[email protected]>
Committed: Thu Jun 8 08:04:33 2017 +0200

----------------------------------------------------------------------
 .../freemarker/core/ConfigurationTest.java      | 12 +--
 .../core/CustomTemplateResolverTest.java        | 12 +--
 .../apache/freemarker/core/Configuration.java   | 50 ++++++------
 .../ConfigurationSettingValueException.java     | 86 --------------------
 .../core/InvalidSettingNameException.java       | 40 +++++++++
 .../core/InvalidSettingValueException.java      | 86 ++++++++++++++++++++
 .../core/MutableProcessingConfiguration.java    | 22 ++---
 .../UnknownConfigurationSettingException.java   | 40 ---------
 .../impl/DefaultTemplateResolver.java           |  4 +-
 9 files changed, 176 insertions(+), 176 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/c42014cc/freemarker-core-test/src/test/java/org/apache/freemarker/core/ConfigurationTest.java
----------------------------------------------------------------------
diff --git 
a/freemarker-core-test/src/test/java/org/apache/freemarker/core/ConfigurationTest.java
 
b/freemarker-core-test/src/test/java/org/apache/freemarker/core/ConfigurationTest.java
index 222952d..064e34a 100644
--- 
a/freemarker-core-test/src/test/java/org/apache/freemarker/core/ConfigurationTest.java
+++ 
b/freemarker-core-test/src/test/java/org/apache/freemarker/core/ConfigurationTest.java
@@ -600,7 +600,7 @@ public class ConfigurationTest extends TestCase {
        
        try {
            cfgB.setSetting(Configuration.ExtendableBuilder.OUTPUT_FORMAT_KEY, 
"null");
-       } catch (ConfigurationSettingValueException e) {
+       } catch (InvalidSettingValueException e) {
            assertThat(e.getCause().getMessage(), 
containsString(UndefinedOutputFormat.class.getSimpleName()));
        }
     }
@@ -674,7 +674,7 @@ public class ConfigurationTest extends TestCase {
         try {
             
cfg.setSetting(Configuration.ExtendableBuilder.REGISTERED_CUSTOM_OUTPUT_FORMATS_KEY_SNAKE_CASE,
 "[TemplateConfiguration()]");
             fail();
-        } catch (ConfigurationSettingValueException e) {
+        } catch (InvalidSettingValueException e) {
             assertThat(e.getMessage(), 
containsString(OutputFormat.class.getSimpleName()));
         }
     }
@@ -911,7 +911,7 @@ public class ConfigurationTest extends TestCase {
         try {
             
cfgB.setSetting(Configuration.ExtendableBuilder.TEMPLATE_UPDATE_DELAY_KEY, "5");
             assertEquals(5000L, (Object) 
cfgB.getTemplateUpdateDelayMilliseconds());
-        } catch (ConfigurationSettingValueException e) {
+        } catch (InvalidSettingValueException e) {
             assertThat(e.getMessage(), containsStringIgnoringCase("unit must 
be specified"));
         }
         
cfgB.setSetting(Configuration.ExtendableBuilder.TEMPLATE_UPDATE_DELAY_KEY, "0");
@@ -919,7 +919,7 @@ public class ConfigurationTest extends TestCase {
         try {
             
cfgB.setSetting(Configuration.ExtendableBuilder.TEMPLATE_UPDATE_DELAY_KEY, "5 
foo");
             assertEquals(5000L, (Object) 
cfgB.getTemplateUpdateDelayMilliseconds());
-        } catch (ConfigurationSettingValueException e) {
+        } catch (InvalidSettingValueException e) {
             assertThat(e.getMessage(), containsStringIgnoringCase("\"foo\""));
         }
         
@@ -1344,7 +1344,7 @@ public class ConfigurationTest extends TestCase {
                 try {
                     cfgB.setSetting(nameCC, value);
                 } catch (Exception e) {
-                    assertThat(e, 
not(instanceOf(UnknownConfigurationSettingException.class)));
+                    assertThat(e, 
not(instanceOf(InvalidSettingNameException.class)));
                     resultCC = e;
                 }
                 
@@ -1353,7 +1353,7 @@ public class ConfigurationTest extends TestCase {
                 try {
                     cfgB.setSetting(nameSC, value);
                 } catch (Exception e) {
-                    assertThat(e, 
not(instanceOf(UnknownConfigurationSettingException.class)));
+                    assertThat(e, 
not(instanceOf(InvalidSettingNameException.class)));
                     resultSC = e;
                 }
                 

http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/c42014cc/freemarker-core-test/src/test/java/org/apache/freemarker/core/CustomTemplateResolverTest.java
----------------------------------------------------------------------
diff --git 
a/freemarker-core-test/src/test/java/org/apache/freemarker/core/CustomTemplateResolverTest.java
 
b/freemarker-core-test/src/test/java/org/apache/freemarker/core/CustomTemplateResolverTest.java
index de4e16d..640dd71 100644
--- 
a/freemarker-core-test/src/test/java/org/apache/freemarker/core/CustomTemplateResolverTest.java
+++ 
b/freemarker-core-test/src/test/java/org/apache/freemarker/core/CustomTemplateResolverTest.java
@@ -132,31 +132,31 @@ public class CustomTemplateResolverTest {
         try {
             new 
Configuration.Builder(Configuration.VERSION_3_0_0).templateCacheStorage(null).build();
             fail();
-        } catch (ConfigurationSettingValueException e) {
+        } catch (InvalidSettingValueException e) {
             // Expected
         }
         try {
             new 
Configuration.Builder(Configuration.VERSION_3_0_0).templateUpdateDelayMilliseconds(null).build();
             fail();
-        } catch (ConfigurationSettingValueException e) {
+        } catch (InvalidSettingValueException e) {
             // Expected
         }
         try {
             new 
Configuration.Builder(Configuration.VERSION_3_0_0).templateLookupStrategy(null).build();
             fail();
-        } catch (ConfigurationSettingValueException e) {
+        } catch (InvalidSettingValueException e) {
             // Expected
         }
         try {
             new 
Configuration.Builder(Configuration.VERSION_3_0_0).localizedTemplateLookup(null).build();
             fail();
-        } catch (ConfigurationSettingValueException e) {
+        } catch (InvalidSettingValueException e) {
             // Expected
         }
         try {
             new 
Configuration.Builder(Configuration.VERSION_3_0_0).templateNameFormat(null).build();
             fail();
-        } catch (ConfigurationSettingValueException e) {
+        } catch (InvalidSettingValueException e) {
             // Expected
         }
 
@@ -183,7 +183,7 @@ public class CustomTemplateResolverTest {
                 try {
                     cfgB.build();
                     fail();
-                } catch (ConfigurationSettingValueException e) {
+                } catch (InvalidSettingValueException e) {
                     // Expected
                 }
             }

http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/c42014cc/freemarker-core/src/main/java/org/apache/freemarker/core/Configuration.java
----------------------------------------------------------------------
diff --git 
a/freemarker-core/src/main/java/org/apache/freemarker/core/Configuration.java 
b/freemarker-core/src/main/java/org/apache/freemarker/core/Configuration.java
index dc86aae..98ae7a9 100644
--- 
a/freemarker-core/src/main/java/org/apache/freemarker/core/Configuration.java
+++ 
b/freemarker-core/src/main/java/org/apache/freemarker/core/Configuration.java
@@ -309,43 +309,43 @@ public final class Configuration implements 
TopLevelConfiguration, CustomStateSc
             for (OutputFormat outputFormat : registeredCustomOutputFormats) {
                 String name = outputFormat.getName();
                 if (name.equals(UndefinedOutputFormat.INSTANCE.getName())) {
-                    throw new ConfigurationSettingValueException(
+                    throw new InvalidSettingValueException(
                             
ExtendableBuilder.REGISTERED_CUSTOM_OUTPUT_FORMATS_KEY, null, false,
                             "The \"" + name + "\" output format can't be 
redefined",
                             null);
                 }
                 if (name.equals(PlainTextOutputFormat.INSTANCE.getName())) {
-                    throw new ConfigurationSettingValueException(
+                    throw new InvalidSettingValueException(
                             
ExtendableBuilder.REGISTERED_CUSTOM_OUTPUT_FORMATS_KEY, null, false,
                             "The \"" + name + "\" output format can't be 
redefined",
                             null);
                 }
                 if (name.length() == 0) {
-                    throw new ConfigurationSettingValueException(
+                    throw new InvalidSettingValueException(
                             
ExtendableBuilder.REGISTERED_CUSTOM_OUTPUT_FORMATS_KEY, null, false,
                             "The output format name can't be 0 long",
                             null);
                 }
                 if (!Character.isLetterOrDigit(name.charAt(0))) {
-                    throw new ConfigurationSettingValueException(
+                    throw new InvalidSettingValueException(
                             
ExtendableBuilder.REGISTERED_CUSTOM_OUTPUT_FORMATS_KEY, null, false,
                             "The output format name must start with letter or 
digit: " + name,
                             null);
                 }
                 if (name.indexOf('+') != -1) {
-                    throw new ConfigurationSettingValueException(
+                    throw new InvalidSettingValueException(
                             
ExtendableBuilder.REGISTERED_CUSTOM_OUTPUT_FORMATS_KEY, null, false,
                             "The output format name can't contain \"+\" 
character: " + name,
                             null);
                 }
                 if (name.indexOf('{') != -1) {
-                    throw new ConfigurationSettingValueException(
+                    throw new InvalidSettingValueException(
                             
ExtendableBuilder.REGISTERED_CUSTOM_OUTPUT_FORMATS_KEY, null, false,
                             "The output format name can't contain \"{\" 
character: " + name,
                             null);
                 }
                 if (name.indexOf('}') != -1) {
-                    throw new ConfigurationSettingValueException(
+                    throw new InvalidSettingValueException(
                             
ExtendableBuilder.REGISTERED_CUSTOM_OUTPUT_FORMATS_KEY, null, false,
                             "The output format name can't contain \"}\" 
character: " + name,
                             null);
@@ -357,7 +357,7 @@ public final class Configuration implements 
TopLevelConfiguration, CustomStateSc
                         throw new IllegalArgumentException(
                                 "Duplicate output format in the collection: " 
+ outputFormat);
                     }
-                    throw new ConfigurationSettingValueException(
+                    throw new InvalidSettingValueException(
                             
ExtendableBuilder.REGISTERED_CUSTOM_OUTPUT_FORMATS_KEY, null, false,
                             "Clashing output format names between " + replaced 
+ " and " + outputFormat + ".",
                             null);
@@ -487,7 +487,7 @@ public final class Configuration implements 
TopLevelConfiguration, CustomStateSc
             TemplateResolver templateResolver,
             String settingName, Object value) {
         if (value != null) {
-            throw new ConfigurationSettingValueException(
+            throw new InvalidSettingValueException(
                     settingName, null, false,
                     "The templateResolver is a "
                     + templateResolver.getClass().getName() + ", which doesn't 
support this setting, hence it "
@@ -498,7 +498,7 @@ public final class Configuration implements 
TopLevelConfiguration, CustomStateSc
 
     private <SelfT extends ExtendableBuilder<SelfT>> void 
wrapAndPutSharedVariables(
             HashMap<String, TemplateModel> wrappedSharedVariables, Map<String, 
Object> rawSharedVariables,
-            ObjectWrapper objectWrapper) throws 
ConfigurationSettingValueException {
+            ObjectWrapper objectWrapper) throws InvalidSettingValueException {
         if (rawSharedVariables.isEmpty()) {
             return;
         }
@@ -507,7 +507,7 @@ public final class Configuration implements 
TopLevelConfiguration, CustomStateSc
             try {
                 wrappedSharedVariables.put(ent.getKey(), 
objectWrapper.wrap(ent.getValue()));
             } catch (TemplateModelException e) {
-                throw new ConfigurationSettingValueException(
+                throw new InvalidSettingValueException(
                         ExtendableBuilder.SHARED_VARIABLES_KEY, null, false,
                         "Failed to wrap shared variable " + 
_StringUtil.jQuote(ent.getKey()),
                         e);
@@ -1861,7 +1861,7 @@ public final class Configuration implements 
TopLevelConfiguration, CustomStateSc
                     } else if ("disable".equals(value)) {
                         setAutoEscapingPolicy(AutoEscapingPolicy.DISABLE);
                     } else {
-                        throw new ConfigurationSettingValueException( name, 
value,
+                        throw new InvalidSettingValueException( name, value,
                                 "No such predefined auto escaping policy 
name");
                     }
                 } else if (OUTPUT_FORMAT_KEY_SNAKE_CASE.equals(name) || 
OUTPUT_FORMAT_KEY_CAMEL_CASE.equals(name)) {
@@ -1877,7 +1877,7 @@ public final class Configuration implements 
TopLevelConfiguration, CustomStateSc
                             value, List.class, true, 
_SettingEvaluationEnvironment.getCurrent());
                     for (Object item : list) {
                         if (!(item instanceof OutputFormat)) {
-                            throw new ConfigurationSettingValueException(name, 
value,
+                            throw new InvalidSettingValueException(name, value,
                                     "List items must be " + 
OutputFormat.class.getName() + " instances.");
                         }
                     }
@@ -1905,7 +1905,7 @@ public final class Configuration implements 
TopLevelConfiguration, CustomStateSc
                             try {
                                 pValue = Integer.parseInt((String) 
ent.getValue());
                             } catch (NumberFormatException e) {
-                                throw new 
ConfigurationSettingValueException(name, value,
+                                throw new InvalidSettingValueException(name, 
value,
                                         "Malformed integer number (shown 
quoted): " + _StringUtil.jQuote(ent.getValue()));
                             }
                             if ("soft".equalsIgnoreCase(pName)) {
@@ -1913,13 +1913,13 @@ public final class Configuration implements 
TopLevelConfiguration, CustomStateSc
                             } else if ("strong".equalsIgnoreCase(pName)) {
                                 strongSize = pValue;
                             } else {
-                                throw new 
ConfigurationSettingValueException(name, value,
+                                throw new InvalidSettingValueException(name, 
value,
                                         "Unsupported cache parameter name 
(shown quoted): "
                                                 + 
_StringUtil.jQuote(ent.getValue()));
                             }
                         }
                         if (softSize == 0 && strongSize == 0) {
-                            throw new ConfigurationSettingValueException(name, 
value,
+                            throw new InvalidSettingValueException(name, value,
                                     "Either cache soft- or strong size must be 
set and non-0.");
                         }
                         setTemplateCacheStorage(new 
MruCacheStorage(strongSize, softSize));
@@ -1948,7 +1948,7 @@ public final class Configuration implements 
TopLevelConfiguration, CustomStateSc
                     } else if (unit.equals("h")) {
                         multipier = 1000 * 60 * 60;
                     } else if (!unit.isEmpty()) {
-                        throw new ConfigurationSettingValueException(name, 
value,
+                        throw new InvalidSettingValueException(name, value,
                                 "Unrecognized time unit " + 
_StringUtil.jQuote(unit) + ". Valid units are: ms, s, m, h");
                     } else {
                         multipier = 0;
@@ -1956,7 +1956,7 @@ public final class Configuration implements 
TopLevelConfiguration, CustomStateSc
 
                     int parsedValue = Integer.parseInt(valueWithoutUnit);
                     if (multipier == 0 && parsedValue != 0) {
-                        throw new ConfigurationSettingValueException(name, 
value,
+                        throw new InvalidSettingValueException(name, value,
                                 "Time unit must be specified for a non-0 value 
(examples: 500 ms, 3 s, 2 m, 1 h).");
                     }
 
@@ -1967,7 +1967,7 @@ public final class Configuration implements 
TopLevelConfiguration, CustomStateSc
                             value, Map.class, false, 
_SettingEvaluationEnvironment.getCurrent());
                     for (Object key : sharedVariables.keySet()) {
                         if (!(key instanceof String)) {
-                            throw new ConfigurationSettingValueException(name, 
null, false,
+                            throw new InvalidSettingValueException(name, null, 
false,
                                     "All keys in this Map must be strings, but 
one of them is an instance of "
                                     + "this class: " + 
_ClassUtil.getShortClassNameOfObject(key), null);
                         }
@@ -1979,7 +1979,7 @@ public final class Configuration implements 
TopLevelConfiguration, CustomStateSc
                     } else if ("static_text".equals(value) || 
"staticText".equals(value)) {
                         setTemplateLanguage(TemplateLanguage.STATIC_TEXT);
                     } else {
-                        throw new ConfigurationSettingValueException(name, 
value, "Unsupported template language name");
+                        throw new InvalidSettingValueException(name, value, 
"Unsupported template language name");
                     }
                 } else if (TAG_SYNTAX_KEY_SNAKE_CASE.equals(name) || 
TAG_SYNTAX_KEY_CAMEL_CASE.equals(name)) {
                     if ("auto_detect".equals(value) || 
"autoDetect".equals(value)) {
@@ -1989,7 +1989,7 @@ public final class Configuration implements 
TopLevelConfiguration, CustomStateSc
                     } else if ("square_bracket".equals(value) || 
"squareBracket".equals(value)) {
                         setTagSyntax(TagSyntax.SQUARE_BRACKET);
                     } else {
-                        throw new ConfigurationSettingValueException(name, 
value, "No such predefined tag syntax name");
+                        throw new InvalidSettingValueException(name, value, 
"No such predefined tag syntax name");
                     }
                 } else if (NAMING_CONVENTION_KEY_SNAKE_CASE.equals(name) || 
NAMING_CONVENTION_KEY_CAMEL_CASE.equals(name)) {
                     if ("auto_detect".equals(value) || 
"autoDetect".equals(value)) {
@@ -1999,7 +1999,7 @@ public final class Configuration implements 
TopLevelConfiguration, CustomStateSc
                     } else if ("camel_case".equals(value) || 
"camelCase".equals(value)) {
                         setNamingConvention(NamingConvention.CAMEL_CASE);
                     } else {
-                        throw new ConfigurationSettingValueException(name, 
value,
+                        throw new InvalidSettingValueException(name, value,
                                 "No such predefined naming convention name.");
                     }
                 } else if (TAB_SIZE_KEY_SNAKE_CASE.equals(name) || 
TAB_SIZE_KEY_CAMEL_CASE.equals(name)) {
@@ -2031,7 +2031,7 @@ public final class Configuration implements 
TopLevelConfiguration, CustomStateSc
                     } else if (value.equalsIgnoreCase("default_2_4_0")) {
                         
setTemplateNameFormat(DefaultTemplateNameFormat.INSTANCE);
                     } else {
-                        throw new ConfigurationSettingValueException(name, 
value,
+                        throw new InvalidSettingValueException(name, value,
                                 "No such predefined template name format");
                     }
                 } else if (TEMPLATE_CONFIGURATIONS_KEY_SNAKE_CASE.equals(name)
@@ -2045,10 +2045,10 @@ public final class Configuration implements 
TopLevelConfiguration, CustomStateSc
                 } else {
                     unknown = true;
                 }
-            } catch (ConfigurationSettingValueException e) {
+            } catch (InvalidSettingValueException e) {
                 throw e;
             } catch (Exception e) {
-                throw new ConfigurationSettingValueException(name, value, e);
+                throw new InvalidSettingValueException(name, value, e);
             }
             if (unknown) {
                 super.setSetting(name, value);

http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/c42014cc/freemarker-core/src/main/java/org/apache/freemarker/core/ConfigurationSettingValueException.java
----------------------------------------------------------------------
diff --git 
a/freemarker-core/src/main/java/org/apache/freemarker/core/ConfigurationSettingValueException.java
 
b/freemarker-core/src/main/java/org/apache/freemarker/core/ConfigurationSettingValueException.java
deleted file mode 100644
index 193ec96..0000000
--- 
a/freemarker-core/src/main/java/org/apache/freemarker/core/ConfigurationSettingValueException.java
+++ /dev/null
@@ -1,86 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.freemarker.core;
-
-import java.util.Date;
-
-import org.apache.freemarker.core.Configuration.ExtendableBuilder;
-import org.apache.freemarker.core.util._StringUtil;
-
-/**
- * Thrown by {@link ExtendableBuilder#setSetting(String, String)}; The setting 
name was recognized, but its value
- * couldn't be parsed or the setting couldn't be set for some other reason. 
This exception should always have a
- * cause exception.
- */
-@SuppressWarnings("serial")
-public class ConfigurationSettingValueException extends ConfigurationException 
{
-
-    public ConfigurationSettingValueException(String name, String value, 
Throwable cause) {
-        this(name, value, true, null, cause);
-    }
-
-    public ConfigurationSettingValueException(String name, String value, 
String reason) {
-        this(name, value, true, reason, null);
-    }
-
-    /**
-     * @param name
-     *         The name of the setting
-     * @param value
-     *         The value of the setting
-     * @param showValue
-     *         Whether the value of the setting should be shown in the error 
message. Set to {@code false} if you want
-     *         to avoid {@link #toString()}-ing the {@code value}.
-     * @param reason
-     *         The explanation of why setting the setting has failed; maybe 
{@code null}, especially if you have a cause
-     *         exception anyway.
-     * @param cause
-     *         The cause exception of this exception (why setting the setting 
was failed)
-     */
-    public ConfigurationSettingValueException(String name, Object value, 
boolean showValue, String reason,
-            Throwable cause) {
-        super(
-                createMessage(
-                    name, value, showValue,
-                    reason != null ? ", because: " : (cause != null ? "; see 
cause exception." : null),
-                    reason),
-                cause);
-    }
-
-    private static String createMessage(String name, Object value, boolean 
showValue, String detail1, String detail2) {
-        StringBuilder sb = new StringBuilder(64);
-        sb.append("Failed to set FreeMarker configuration setting 
").append(_StringUtil.jQuote(name));
-        if (showValue) {
-            sb.append(" to value ")
-                    .append(
-                            value instanceof Number || value instanceof 
Boolean || value instanceof Date ? value
-                            : _StringUtil.jQuote(value));
-        } else {
-            sb.append(" to the specified value");
-        }
-        if (detail1 != null) {
-            sb.append(detail1);
-        }
-        if (detail2 != null) {
-            sb.append(detail2);
-        }
-        return sb.toString();
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/c42014cc/freemarker-core/src/main/java/org/apache/freemarker/core/InvalidSettingNameException.java
----------------------------------------------------------------------
diff --git 
a/freemarker-core/src/main/java/org/apache/freemarker/core/InvalidSettingNameException.java
 
b/freemarker-core/src/main/java/org/apache/freemarker/core/InvalidSettingNameException.java
new file mode 100644
index 0000000..912619c
--- /dev/null
+++ 
b/freemarker-core/src/main/java/org/apache/freemarker/core/InvalidSettingNameException.java
@@ -0,0 +1,40 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.freemarker.core;
+
+import org.apache.freemarker.core.Configuration.ExtendableBuilder;
+import org.apache.freemarker.core.util._StringUtil;
+
+/**
+ * Thrown by {@link ExtendableBuilder#setSetting(String, String)} if the 
setting name was not recognized.
+ */
+@SuppressWarnings("serial")
+public class InvalidSettingNameException extends ConfigurationException {
+
+    InvalidSettingNameException(String name, String correctedName) {
+        super("Unknown FreeMarker configuration setting: " + 
_StringUtil.jQuote(name)
+                + (correctedName == null ? "" : ". You may meant: " + 
_StringUtil.jQuote(correctedName)));
+    }
+
+    InvalidSettingNameException(String name, Version removedInVersion) {
+        super("Unknown FreeMarker configuration setting: " + 
_StringUtil.jQuote(name)
+                + (removedInVersion == null ? "" : ". This setting was removed 
in version " + removedInVersion));
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/c42014cc/freemarker-core/src/main/java/org/apache/freemarker/core/InvalidSettingValueException.java
----------------------------------------------------------------------
diff --git 
a/freemarker-core/src/main/java/org/apache/freemarker/core/InvalidSettingValueException.java
 
b/freemarker-core/src/main/java/org/apache/freemarker/core/InvalidSettingValueException.java
new file mode 100644
index 0000000..1acbefa
--- /dev/null
+++ 
b/freemarker-core/src/main/java/org/apache/freemarker/core/InvalidSettingValueException.java
@@ -0,0 +1,86 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.freemarker.core;
+
+import java.util.Date;
+
+import org.apache.freemarker.core.Configuration.ExtendableBuilder;
+import org.apache.freemarker.core.util._StringUtil;
+
+/**
+ * Thrown by {@link ExtendableBuilder#setSetting(String, String)}; The setting 
name was recognized, but its value
+ * couldn't be parsed or the setting couldn't be set for some other reason. 
This exception should always have a
+ * cause exception.
+ */
+@SuppressWarnings("serial")
+public class InvalidSettingValueException extends ConfigurationException {
+
+    public InvalidSettingValueException(String name, String value, Throwable 
cause) {
+        this(name, value, true, null, cause);
+    }
+
+    public InvalidSettingValueException(String name, String value, String 
reason) {
+        this(name, value, true, reason, null);
+    }
+
+    /**
+     * @param name
+     *         The name of the setting
+     * @param value
+     *         The value of the setting
+     * @param showValue
+     *         Whether the value of the setting should be shown in the error 
message. Set to {@code false} if you want
+     *         to avoid {@link #toString()}-ing the {@code value}.
+     * @param reason
+     *         The explanation of why setting the setting has failed; maybe 
{@code null}, especially if you have a cause
+     *         exception anyway.
+     * @param cause
+     *         The cause exception of this exception (why setting the setting 
was failed)
+     */
+    public InvalidSettingValueException(String name, Object value, boolean 
showValue, String reason,
+            Throwable cause) {
+        super(
+                createMessage(
+                    name, value, showValue,
+                    reason != null ? ", because: " : (cause != null ? "; see 
cause exception." : null),
+                    reason),
+                cause);
+    }
+
+    private static String createMessage(String name, Object value, boolean 
showValue, String detail1, String detail2) {
+        StringBuilder sb = new StringBuilder(64);
+        sb.append("Failed to set FreeMarker configuration setting 
").append(_StringUtil.jQuote(name));
+        if (showValue) {
+            sb.append(" to value ")
+                    .append(
+                            value instanceof Number || value instanceof 
Boolean || value instanceof Date ? value
+                            : _StringUtil.jQuote(value));
+        } else {
+            sb.append(" to the specified value");
+        }
+        if (detail1 != null) {
+            sb.append(detail1);
+        }
+        if (detail2 != null) {
+            sb.append(detail2);
+        }
+        return sb.toString();
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/c42014cc/freemarker-core/src/main/java/org/apache/freemarker/core/MutableProcessingConfiguration.java
----------------------------------------------------------------------
diff --git 
a/freemarker-core/src/main/java/org/apache/freemarker/core/MutableProcessingConfiguration.java
 
b/freemarker-core/src/main/java/org/apache/freemarker/core/MutableProcessingConfiguration.java
index d490bae..eb28dac 100644
--- 
a/freemarker-core/src/main/java/org/apache/freemarker/core/MutableProcessingConfiguration.java
+++ 
b/freemarker-core/src/main/java/org/apache/freemarker/core/MutableProcessingConfiguration.java
@@ -1854,8 +1854,8 @@ public abstract class 
MutableProcessingConfiguration<SelfT extends MutableProces
      * @param name the name of the setting.
      * @param value the string that describes the new value of the setting.
      * 
-     * @throws UnknownConfigurationSettingException if the name is wrong.
-     * @throws ConfigurationSettingValueException if the new value of the 
setting can't be set for any other reasons.
+     * @throws InvalidSettingNameException if the name is wrong.
+     * @throws InvalidSettingValueException if the new value of the setting 
can't be set for any other reasons.
      */
     public void setSetting(String name, String value) throws 
ConfigurationException {
         boolean unknown = false;
@@ -1912,7 +1912,7 @@ public abstract class 
MutableProcessingConfiguration<SelfT extends MutableProces
                             && this instanceof 
Configuration.ExtendableBuilder) {
                         unsetTemplateExceptionHandler();
                     } else {
-                        throw new ConfigurationSettingValueException(
+                        throw new InvalidSettingValueException(
                                 name, value,
                                 "No such predefined template exception handler 
name");
                     }
@@ -1927,7 +1927,7 @@ public abstract class 
MutableProcessingConfiguration<SelfT extends MutableProces
                     } else if ("conservative".equalsIgnoreCase(value)) {
                         
setArithmeticEngine(ConservativeArithmeticEngine.INSTANCE);
                     } else {
-                        throw new ConfigurationSettingValueException(
+                        throw new InvalidSettingValueException(
                                 name, value, "No such predefined arithmetical 
engine name");
                     }
                 } else {
@@ -1981,7 +1981,7 @@ public abstract class 
MutableProcessingConfiguration<SelfT extends MutableProces
                         } else if (segmentKey.equals(TRUSTED_TEMPLATES)) {
                             trustedTemplates = segmentValue;
                         } else {
-                            throw new ConfigurationSettingValueException(name, 
value,
+                            throw new InvalidSettingValueException(name, value,
                                     "Unrecognized list segment key: " + 
_StringUtil.jQuote(segmentKey) +
                                             ". Supported keys are: \"" + 
ALLOWED_CLASSES + "\", \"" +
                                             TRUSTED_TEMPLATES + "\"");
@@ -1994,7 +1994,7 @@ public abstract class 
MutableProcessingConfiguration<SelfT extends MutableProces
                                     value, TemplateClassResolver.class, false,
                                     
_SettingEvaluationEnvironment.getCurrent()));
                 } else {
-                    throw new ConfigurationSettingValueException(
+                    throw new InvalidSettingValueException(
                             name, value,
                             "Not predefined class resolved name, nor follows 
class resolver definition syntax, nor "
                             + "looks like class name");
@@ -2014,10 +2014,10 @@ public abstract class 
MutableProcessingConfiguration<SelfT extends MutableProces
             } else {
                 unknown = true;
             }
-        } catch (ConfigurationSettingValueException e) {
+        } catch (InvalidSettingValueException e) {
             throw e;
         } catch (Exception e) {
-            throw new ConfigurationSettingValueException(name, value, e);
+            throw new InvalidSettingValueException(name, value, e);
         }
         if (unknown) {
             throw unknownSettingException(name);
@@ -2074,11 +2074,11 @@ public abstract class 
MutableProcessingConfiguration<SelfT extends MutableProces
     /**
      * Creates the exception that should be thrown when a setting name isn't 
recognized.
      */
-    protected final UnknownConfigurationSettingException 
unknownSettingException(String name) {
+    protected final InvalidSettingNameException unknownSettingException(String 
name) {
         Version removalVersion = getRemovalVersionForUnknownSetting(name);
          return removalVersion != null
-                ? new UnknownConfigurationSettingException(name, 
removalVersion)
-                : new UnknownConfigurationSettingException(name, 
getCorrectedNameForUnknownSetting(name));
+                ? new InvalidSettingNameException(name, removalVersion)
+                : new InvalidSettingNameException(name, 
getCorrectedNameForUnknownSetting(name));
     }
 
     /**

http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/c42014cc/freemarker-core/src/main/java/org/apache/freemarker/core/UnknownConfigurationSettingException.java
----------------------------------------------------------------------
diff --git 
a/freemarker-core/src/main/java/org/apache/freemarker/core/UnknownConfigurationSettingException.java
 
b/freemarker-core/src/main/java/org/apache/freemarker/core/UnknownConfigurationSettingException.java
deleted file mode 100644
index a4e562c..0000000
--- 
a/freemarker-core/src/main/java/org/apache/freemarker/core/UnknownConfigurationSettingException.java
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.freemarker.core;
-
-import org.apache.freemarker.core.Configuration.ExtendableBuilder;
-import org.apache.freemarker.core.util._StringUtil;
-
-/**
- * Thrown by {@link ExtendableBuilder#setSetting(String, String)} if the 
setting name was not recognized.
- */
-@SuppressWarnings("serial")
-public class UnknownConfigurationSettingException extends 
ConfigurationException {
-
-    UnknownConfigurationSettingException(String name, String correctedName) {
-        super("Unknown FreeMarker configuration setting: " + 
_StringUtil.jQuote(name)
-                + (correctedName == null ? "" : ". You may meant: " + 
_StringUtil.jQuote(correctedName)));
-    }
-
-    UnknownConfigurationSettingException(String name, Version 
removedInVersion) {
-        super("Unknown FreeMarker configuration setting: " + 
_StringUtil.jQuote(name)
-                + (removedInVersion == null ? "" : ". This setting was removed 
in version " + removedInVersion));
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/c42014cc/freemarker-core/src/main/java/org/apache/freemarker/core/templateresolver/impl/DefaultTemplateResolver.java
----------------------------------------------------------------------
diff --git 
a/freemarker-core/src/main/java/org/apache/freemarker/core/templateresolver/impl/DefaultTemplateResolver.java
 
b/freemarker-core/src/main/java/org/apache/freemarker/core/templateresolver/impl/DefaultTemplateResolver.java
index 5cebcb8..54c830d 100644
--- 
a/freemarker-core/src/main/java/org/apache/freemarker/core/templateresolver/impl/DefaultTemplateResolver.java
+++ 
b/freemarker-core/src/main/java/org/apache/freemarker/core/templateresolver/impl/DefaultTemplateResolver.java
@@ -36,7 +36,7 @@ import java.util.StringTokenizer;
 
 import org.apache.freemarker.core.Configuration;
 import org.apache.freemarker.core.ConfigurationException;
-import org.apache.freemarker.core.ConfigurationSettingValueException;
+import org.apache.freemarker.core.InvalidSettingValueException;
 import org.apache.freemarker.core.Template;
 import org.apache.freemarker.core.TemplateConfiguration;
 import org.apache.freemarker.core.TemplateLanguage;
@@ -128,7 +128,7 @@ public class DefaultTemplateResolver extends 
TemplateResolver {
 
     private void checkDependencyNotNull(String name, Object value) {
         if (value == null) {
-            throw new ConfigurationSettingValueException(
+            throw new InvalidSettingValueException(
                     name, null, false,
                     "This Configuration setting must be set and non-null when 
the TemplateResolver is a(n) "
                     + this.getClass().getName() + ".", null);


Reply via email to