freemarker-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ddek...@apache.org
Subject [5/7] incubator-freemarker git commit: `TemplateModelException` was removed, replaced with `TemplateException` on all places, except for `ObjectWrapper.wrap(Object)` and `wrapAsAPI(Object)`, which now throws `ObjectWrappingException` instead (that extend
Date Sat, 19 Aug 2017 23:36:39 GMT
http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/d73da6da/freemarker-core/src/main/java/org/apache/freemarker/core/BuiltInsForNodes.java
----------------------------------------------------------------------
diff --git a/freemarker-core/src/main/java/org/apache/freemarker/core/BuiltInsForNodes.java b/freemarker-core/src/main/java/org/apache/freemarker/core/BuiltInsForNodes.java
index 5174c3e..178c0e2 100644
--- a/freemarker-core/src/main/java/org/apache/freemarker/core/BuiltInsForNodes.java
+++ b/freemarker-core/src/main/java/org/apache/freemarker/core/BuiltInsForNodes.java
@@ -19,12 +19,11 @@
 
 package org.apache.freemarker.core;
 
-import static org.apache.freemarker.core.util.CallableUtils.getStringArgument;
+import static org.apache.freemarker.core.util.CallableUtils.*;
 
 import org.apache.freemarker.core.model.ArgumentArrayLayout;
 import org.apache.freemarker.core.model.TemplateFunctionModel;
 import org.apache.freemarker.core.model.TemplateModel;
-import org.apache.freemarker.core.model.TemplateModelException;
 import org.apache.freemarker.core.model.TemplateNodeModel;
 import org.apache.freemarker.core.model.TemplateNodeModelEx;
 import org.apache.freemarker.core.model.impl.SimpleScalar;
@@ -37,7 +36,7 @@ class BuiltInsForNodes {
     
     static class ancestorsBI extends BuiltInForNode {
        @Override
-    TemplateModel calculateResult(TemplateNodeModel nodeModel, Environment env) throws TemplateModelException {
+    TemplateModel calculateResult(TemplateNodeModel nodeModel, Environment env) throws TemplateException {
            AncestorSequence result = new AncestorSequence(env);
            TemplateNodeModel parent = nodeModel.getParentNode();
            while (parent != null) {
@@ -109,14 +108,14 @@ class BuiltInsForNodes {
     
     static class childrenBI extends BuiltInForNode {
        @Override
-    TemplateModel calculateResult(TemplateNodeModel nodeModel, Environment env) throws TemplateModelException {
+    TemplateModel calculateResult(TemplateNodeModel nodeModel, Environment env) throws TemplateException {
             return nodeModel.getChildNodes();
        }
     }
     
     static class node_nameBI extends BuiltInForNode {
        @Override
-    TemplateModel calculateResult(TemplateNodeModel nodeModel, Environment env) throws TemplateModelException {
+    TemplateModel calculateResult(TemplateNodeModel nodeModel, Environment env) throws TemplateException {
             return new SimpleScalar(nodeModel.getNodeName());
        }
     }
@@ -124,7 +123,7 @@ class BuiltInsForNodes {
     
     static class node_namespaceBI extends BuiltInForNode {
         @Override
-        TemplateModel calculateResult(TemplateNodeModel nodeModel, Environment env) throws TemplateModelException {
+        TemplateModel calculateResult(TemplateNodeModel nodeModel, Environment env) throws TemplateException {
             String nsURI = nodeModel.getNodeNamespace();
             return nsURI == null ? null : new SimpleScalar(nsURI);
         }
@@ -132,21 +131,21 @@ class BuiltInsForNodes {
     
     static class node_typeBI extends BuiltInForNode {
        @Override
-    TemplateModel calculateResult(TemplateNodeModel nodeModel, Environment env) throws TemplateModelException {
+    TemplateModel calculateResult(TemplateNodeModel nodeModel, Environment env) throws TemplateException {
             return new SimpleScalar(nodeModel.getNodeType());
         }
     }
 
     static class parentBI extends BuiltInForNode {
        @Override
-    TemplateModel calculateResult(TemplateNodeModel nodeModel, Environment env) throws TemplateModelException {
+    TemplateModel calculateResult(TemplateNodeModel nodeModel, Environment env) throws TemplateException {
             return nodeModel.getParentNode();
        }
     }
     
     static class rootBI extends BuiltInForNode {
        @Override
-    TemplateModel calculateResult(TemplateNodeModel nodeModel, Environment env) throws TemplateModelException {
+    TemplateModel calculateResult(TemplateNodeModel nodeModel, Environment env) throws TemplateException {
             TemplateNodeModel result = nodeModel;
             TemplateNodeModel parent = nodeModel.getParentNode();
             while (parent != null) {
@@ -159,14 +158,14 @@ class BuiltInsForNodes {
 
     static class previousSiblingBI extends BuiltInForNodeEx {
         @Override
-        TemplateModel calculateResult(TemplateNodeModelEx nodeModel, Environment env) throws TemplateModelException {
+        TemplateModel calculateResult(TemplateNodeModelEx nodeModel, Environment env) throws TemplateException {
             return nodeModel.getPreviousSibling();
         }
     }
 
     static class nextSiblingBI extends  BuiltInForNodeEx {
         @Override
-        TemplateModel calculateResult(TemplateNodeModelEx nodeModel, Environment env) throws TemplateModelException {
+        TemplateModel calculateResult(TemplateNodeModelEx nodeModel, Environment env) throws TemplateException {
             return nodeModel.getNextSibling();
         }
     }

http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/d73da6da/freemarker-core/src/main/java/org/apache/freemarker/core/BuiltInsForNumbers.java
----------------------------------------------------------------------
diff --git a/freemarker-core/src/main/java/org/apache/freemarker/core/BuiltInsForNumbers.java b/freemarker-core/src/main/java/org/apache/freemarker/core/BuiltInsForNumbers.java
index c197756..447a644 100644
--- a/freemarker-core/src/main/java/org/apache/freemarker/core/BuiltInsForNumbers.java
+++ b/freemarker-core/src/main/java/org/apache/freemarker/core/BuiltInsForNumbers.java
@@ -26,7 +26,6 @@ import java.util.Date;
 import org.apache.freemarker.core.model.TemplateBooleanModel;
 import org.apache.freemarker.core.model.TemplateDateModel;
 import org.apache.freemarker.core.model.TemplateModel;
-import org.apache.freemarker.core.model.TemplateModelException;
 import org.apache.freemarker.core.model.TemplateNumberModel;
 import org.apache.freemarker.core.model.impl.SimpleDate;
 import org.apache.freemarker.core.model.impl.SimpleNumber;
@@ -42,17 +41,17 @@ class BuiltInsForNumbers {
     private static abstract class abcBI extends BuiltInForNumber {
 
         @Override
-        TemplateModel calculateResult(Number num, TemplateModel model) throws TemplateModelException {
+        TemplateModel calculateResult(Number num, TemplateModel model) throws TemplateException {
             final int n;
             try {
                 n = _NumberUtils.toIntExact(num);
             } catch (ArithmeticException e) {
-                throw new _TemplateModelException(target,
+                throw new TemplateException(target,
                         "The left side operand value isn't compatible with ?", key, ": ", e.getMessage());
          
             }
             if (n <= 0) {
-                throw new _TemplateModelException(target,
+                throw new TemplateException(target,
                         "The left side operand of to ?", key, " must be at least 1, but was ", Integer.valueOf(n), ".");
             }
             return new SimpleScalar(toABC(n));
@@ -82,7 +81,7 @@ class BuiltInsForNumbers {
     
     static class absBI extends BuiltInForNumber {
         @Override
-        TemplateModel calculateResult(Number num, TemplateModel model) throws TemplateModelException {
+        TemplateModel calculateResult(Number num, TemplateModel model) throws TemplateException {
             if (num instanceof Integer) {
                 int n = num.intValue();
                 if (n < 0) {
@@ -140,7 +139,7 @@ class BuiltInsForNumbers {
                     return model;
                 }
             } else {
-                throw new _TemplateModelException("Unsupported number class: ", num.getClass());
+                throw new TemplateException("Unsupported number class: ", num.getClass());
             }            
         }
     }
@@ -201,7 +200,7 @@ class BuiltInsForNumbers {
 
     static class is_infiniteBI extends BuiltInForNumber {
         @Override
-        TemplateModel calculateResult(Number num, TemplateModel model) throws TemplateModelException {
+        TemplateModel calculateResult(Number num, TemplateModel model) throws TemplateException {
             return _NumberUtils.isInfinite(num) ? TemplateBooleanModel.TRUE : TemplateBooleanModel.FALSE;
         }
     }
@@ -209,7 +208,7 @@ class BuiltInsForNumbers {
 
     static class is_nanBI extends BuiltInForNumber {
         @Override
-        TemplateModel calculateResult(Number num, TemplateModel model) throws TemplateModelException {
+        TemplateModel calculateResult(Number num, TemplateModel model) throws TemplateException {
             return _NumberUtils.isNaN(num) ? TemplateBooleanModel.TRUE : TemplateBooleanModel.FALSE;
         }
     }
@@ -244,7 +243,7 @@ class BuiltInsForNumbers {
         
         @Override
         TemplateModel calculateResult(Number num, TemplateModel model)
-        throws TemplateModelException {
+        throws TemplateException {
             return new SimpleDate(new Date(safeToLong(num)), dateType);
         }
     }
@@ -267,11 +266,11 @@ class BuiltInsForNumbers {
         }
     }
 
-    private static long safeToLong(Number num) throws TemplateModelException {
+    private static long safeToLong(Number num) throws TemplateException {
         if (num instanceof Double) {
             double d = Math.round(num.doubleValue());
             if (d > Long.MAX_VALUE || d < Long.MIN_VALUE) {
-                throw new _TemplateModelException(
+                throw new TemplateException(
                         "Number doesn't fit into a 64 bit signed integer (long): ", Double.valueOf(d));
             } else {
                 return (long) d;
@@ -279,7 +278,7 @@ class BuiltInsForNumbers {
         } else if (num instanceof Float) {
             float f = Math.round(num.floatValue());
             if (f > Long.MAX_VALUE || f < Long.MIN_VALUE) {
-                throw new _TemplateModelException(
+                throw new TemplateException(
                         "Number doesn't fit into a 64 bit signed integer (long): ", Float.valueOf(f));
             } else {
                 return (long) f;
@@ -287,22 +286,22 @@ class BuiltInsForNumbers {
         } else if (num instanceof BigDecimal) {
             BigDecimal bd = ((BigDecimal) num).setScale(0, BigDecimal.ROUND_HALF_UP);
             if (bd.compareTo(BIG_DECIMAL_LONG_MAX) > 0 || bd.compareTo(BIG_DECIMAL_LONG_MIN) < 0) {
-                throw new _TemplateModelException("Number doesn't fit into a 64 bit signed integer (long): ", bd);
+                throw new TemplateException("Number doesn't fit into a 64 bit signed integer (long): ", bd);
             } else {
                 return bd.longValue();
             }
         } else if (num instanceof BigInteger) {
             BigInteger bi = (BigInteger) num;
             if (bi.compareTo(BIG_INTEGER_LONG_MAX) > 0 || bi.compareTo(BIG_INTEGER_LONG_MIN) < 0) {
-                throw new _TemplateModelException("Number doesn't fit into a 64 bit signed integer (long): ", bi);
+                throw new TemplateException("Number doesn't fit into a 64 bit signed integer (long): ", bi);
             } else {
                 return bi.longValue();
             }
         } else if (num instanceof Long || num instanceof Integer || num instanceof Byte || num instanceof Short) {
             return num.longValue();
         } else {
-            // Should add Atomic* types in 2.4...
-            throw new _TemplateModelException("Unsupported number type: ", num.getClass());
+            // TODO [FM3] Should add Atomic* types in 2.4...
+            throw new TemplateException("Unsupported number type: ", num.getClass());
         }
     }
     

http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/d73da6da/freemarker-core/src/main/java/org/apache/freemarker/core/BuiltInsForOutputFormatRelated.java
----------------------------------------------------------------------
diff --git a/freemarker-core/src/main/java/org/apache/freemarker/core/BuiltInsForOutputFormatRelated.java b/freemarker-core/src/main/java/org/apache/freemarker/core/BuiltInsForOutputFormatRelated.java
index 5ab518c..e1e7b5f 100644
--- a/freemarker-core/src/main/java/org/apache/freemarker/core/BuiltInsForOutputFormatRelated.java
+++ b/freemarker-core/src/main/java/org/apache/freemarker/core/BuiltInsForOutputFormatRelated.java
@@ -64,7 +64,7 @@ class BuiltInsForOutputFormatRelated {
                     // ATTENTION: Keep this logic in sync. with ${...}'s logic!
                     String lhoPlainTtext = lhoOF.getSourcePlainText(lhoMO);
                     if (lhoPlainTtext == null) {
-                        throw new _TemplateModelException(target,
+                        throw new TemplateException(target,
                                 "The left side operand of ?", key, " is in ", new _DelayedToString(lhoOF),
                                 " format, which differs from the current output format, ",
                                 new _DelayedToString(contextOF), ". Conversion wasn't possible.");

http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/d73da6da/freemarker-core/src/main/java/org/apache/freemarker/core/BuiltInsForSequences.java
----------------------------------------------------------------------
diff --git a/freemarker-core/src/main/java/org/apache/freemarker/core/BuiltInsForSequences.java b/freemarker-core/src/main/java/org/apache/freemarker/core/BuiltInsForSequences.java
index 857e7e3..d0fa358 100644
--- a/freemarker-core/src/main/java/org/apache/freemarker/core/BuiltInsForSequences.java
+++ b/freemarker-core/src/main/java/org/apache/freemarker/core/BuiltInsForSequences.java
@@ -36,7 +36,6 @@ import org.apache.freemarker.core.model.TemplateDateModel;
 import org.apache.freemarker.core.model.TemplateFunctionModel;
 import org.apache.freemarker.core.model.TemplateHashModel;
 import org.apache.freemarker.core.model.TemplateModel;
-import org.apache.freemarker.core.model.TemplateModelException;
 import org.apache.freemarker.core.model.TemplateModelIterator;
 import org.apache.freemarker.core.model.TemplateNumberModel;
 import org.apache.freemarker.core.model.TemplateScalarModel;
@@ -101,7 +100,7 @@ class BuiltInsForSequences {
 
             @Override
             public TemplateModel get(final int chunkIndex)
-                    throws TemplateModelException {
+                    throws TemplateException {
                 if (chunkIndex >= numberOfChunks) {
                     return null;
                 }
@@ -112,7 +111,7 @@ class BuiltInsForSequences {
 
                     @Override
                     public TemplateModel get(int relIndex)
-                            throws TemplateModelException {
+                            throws TemplateException {
                         int absIndex = baseIndex + relIndex;
                         if (absIndex < wrappedTsm.size()) {
                             return wrappedTsm.get(absIndex);
@@ -124,7 +123,7 @@ class BuiltInsForSequences {
                     }
 
                     @Override
-                    public int size() throws TemplateModelException {
+                    public int size() throws TemplateException {
                         return fillerItem != null || chunkIndex + 1 < numberOfChunks
                                 ? chunkSize
                                 : wrappedTsm.size() - baseIndex;
@@ -134,14 +133,14 @@ class BuiltInsForSequences {
             }
 
             @Override
-            public int size() throws TemplateModelException {
+            public int size() throws TemplateException {
                 return numberOfChunks;
             }
             
         }
         
         @Override
-        TemplateModel calculateResult(TemplateSequenceModel tsm) throws TemplateModelException {
+        TemplateModel calculateResult(TemplateSequenceModel tsm) throws TemplateException {
             return new BIMethod(tsm);
         }
         
@@ -169,7 +168,7 @@ class BuiltInsForSequences {
         }        
         
         private TemplateModel calculateResultForSequence(TemplateSequenceModel seq)
-        throws TemplateModelException {
+        throws TemplateException {
             if (seq.size() == 0) {
                 return null;
             }
@@ -177,7 +176,7 @@ class BuiltInsForSequences {
         }
         
         private TemplateModel calculateResultForColletion(TemplateCollectionModel coll)
-        throws TemplateModelException {
+        throws TemplateException {
             TemplateModelIterator iter = coll.iterator();
             if (!iter.hasNext()) {
                 return null;
@@ -272,7 +271,7 @@ class BuiltInsForSequences {
     static class lastBI extends BuiltInForSequence {
         @Override
         TemplateModel calculateResult(TemplateSequenceModel tsm)
-        throws TemplateModelException {
+        throws TemplateException {
             if (tsm.size() == 0) {
                 return null;
             }
@@ -289,12 +288,12 @@ class BuiltInsForSequences {
             }
 
             @Override
-            public TemplateModel get(int index) throws TemplateModelException {
+            public TemplateModel get(int index) throws TemplateException {
                 return seq.get(seq.size() - 1 - index);
             }
 
             @Override
-            public int size() throws TemplateModelException {
+            public int size() throws TemplateException {
                 return seq.size();
             }
         }

http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/d73da6da/freemarker-core/src/main/java/org/apache/freemarker/core/BuiltInsForStringsBasic.java
----------------------------------------------------------------------
diff --git a/freemarker-core/src/main/java/org/apache/freemarker/core/BuiltInsForStringsBasic.java b/freemarker-core/src/main/java/org/apache/freemarker/core/BuiltInsForStringsBasic.java
index 119a1b8..1eaeb2d 100644
--- a/freemarker-core/src/main/java/org/apache/freemarker/core/BuiltInsForStringsBasic.java
+++ b/freemarker-core/src/main/java/org/apache/freemarker/core/BuiltInsForStringsBasic.java
@@ -30,7 +30,6 @@ import org.apache.freemarker.core.model.ArgumentArrayLayout;
 import org.apache.freemarker.core.model.TemplateBooleanModel;
 import org.apache.freemarker.core.model.TemplateFunctionModel;
 import org.apache.freemarker.core.model.TemplateModel;
-import org.apache.freemarker.core.model.TemplateModelException;
 import org.apache.freemarker.core.model.TemplateScalarModel;
 import org.apache.freemarker.core.model.impl.SimpleNumber;
 import org.apache.freemarker.core.model.impl.SimpleScalar;
@@ -304,7 +303,7 @@ class BuiltInsForStringsBasic {
         }
         
         @Override
-        TemplateModel calculateResult(String s, Environment env) throws TemplateModelException {
+        TemplateModel calculateResult(String s, Environment env) throws TemplateException {
             return new KeepAfterMethod(s);
         }
         
@@ -362,7 +361,7 @@ class BuiltInsForStringsBasic {
         }
         
         @Override
-        TemplateModel calculateResult(String s, Environment env) throws TemplateModelException {
+        TemplateModel calculateResult(String s, Environment env) throws TemplateException {
             return new KeepAfterMethod(s);
         }
         
@@ -411,7 +410,7 @@ class BuiltInsForStringsBasic {
         }
         
         @Override
-        TemplateModel calculateResult(String s, Environment env) throws TemplateModelException {
+        TemplateModel calculateResult(String s, Environment env) throws TemplateException {
             return new KeepUntilMethod(s);
         }
         
@@ -467,7 +466,7 @@ class BuiltInsForStringsBasic {
         }
         
         @Override
-        TemplateModel calculateResult(String s, Environment env) throws TemplateModelException {
+        TemplateModel calculateResult(String s, Environment env) throws TemplateException {
             return new KeepUntilMethod(s);
         }
         
@@ -635,7 +634,7 @@ class BuiltInsForStringsBasic {
         }
         
         @Override
-        TemplateModel calculateResult(String s, Environment env) throws TemplateModelException {
+        TemplateModel calculateResult(String s, Environment env) throws TemplateException {
             return new SplitMethod(s);
         }
         
@@ -722,7 +721,7 @@ class BuiltInsForStringsBasic {
             }
 
             private TemplateException newIndexGreaterThanLengthException(
-                    int argIdx, int idx, final int len) throws TemplateModelException {
+                    int argIdx, int idx, final int len) throws TemplateException {
                 return newArgumentValueException(
                         argIdx,
                         "mustn't be greater than the length of the string, " + len + ", but it was " + idx + ".",
@@ -730,7 +729,7 @@ class BuiltInsForStringsBasic {
             }
 
             private TemplateException newIndexLessThan0Exception(
-                    int argIdx, int idx) throws TemplateModelException {
+                    int argIdx, int idx) throws TemplateException {
                 return newArgumentValueException(
                         argIdx, "must be at least 0, but was " + idx + ".", this);
             }

http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/d73da6da/freemarker-core/src/main/java/org/apache/freemarker/core/BuiltInsForStringsEncoding.java
----------------------------------------------------------------------
diff --git a/freemarker-core/src/main/java/org/apache/freemarker/core/BuiltInsForStringsEncoding.java b/freemarker-core/src/main/java/org/apache/freemarker/core/BuiltInsForStringsEncoding.java
index 8c6a6df..e36572c 100644
--- a/freemarker-core/src/main/java/org/apache/freemarker/core/BuiltInsForStringsEncoding.java
+++ b/freemarker-core/src/main/java/org/apache/freemarker/core/BuiltInsForStringsEncoding.java
@@ -19,7 +19,7 @@
 
 package org.apache.freemarker.core;
 
-import static org.apache.freemarker.core.util.CallableUtils.getStringArgument;
+import static org.apache.freemarker.core.util.CallableUtils.*;
 
 import java.io.UnsupportedEncodingException;
 import java.nio.charset.Charset;
@@ -28,7 +28,6 @@ import java.nio.charset.UnsupportedCharsetException;
 import org.apache.freemarker.core.model.ArgumentArrayLayout;
 import org.apache.freemarker.core.model.TemplateFunctionModel;
 import org.apache.freemarker.core.model.TemplateModel;
-import org.apache.freemarker.core.model.TemplateModelException;
 import org.apache.freemarker.core.model.TemplateScalarModel;
 import org.apache.freemarker.core.model.impl.SimpleScalar;
 import org.apache.freemarker.core.util._StringUtils;
@@ -173,25 +172,24 @@ class BuiltInsForStringsEncoding {
         }
 
         @Override
-        public String getAsString() throws TemplateModelException {
+        public String getAsString() throws TemplateException {
             if (cachedResult == null) {
                 Charset charset = env.getEffectiveURLEscapingCharset();
                 if (charset == null) {
-                    throw new TemplateModelException(
-                            "To do URL encoding, the framework that encloses "
-                            + "FreeMarker must specify the output encoding "
-                            + "or the URL encoding charset, so ask the "
-                            + "programmers to fix it. Or, as a last chance, "
-                            + "you can set the url_encoding_charset setting in "
-                            + "the template, e.g. "
-                            + "<#setting urlEscapingCharset='ISO-8859-1'>, or "
-                            + "give the charset explicitly to the buit-in, e.g. "
+                    throw new TemplateException(
+                            "To do URL encoding, the framework that encloses FreeMarker must specify the \"",
+                            Configuration.Builder.OUTPUT_ENCODING_KEY, "\" setting or the \"",
+                            Configuration.Builder.URL_ESCAPING_CHARSET_KEY,
+                            "\" setting, so ask the programmers to set them. Or, as a last chance, you can set the "
+                            + "url_encoding_charset setting in the template, e.g. <#setting ",
+                            Configuration.Builder.URL_ESCAPING_CHARSET_KEY,
+                            "='ISO-8859-1'>, or give the charset explicitly to the built-in, e.g. "
                             + "foo?url('ISO-8859-1').");
                 }
                 try {
                     cachedResult = encodeWithCharset(charset);
                 } catch (UnsupportedEncodingException e) {
-                    throw new _TemplateModelException(e, "Failed to execute URL encoding.");
+                    throw new TemplateException(e, "Failed to execute URL encoding.");
                 }
             }
             return cachedResult;

http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/d73da6da/freemarker-core/src/main/java/org/apache/freemarker/core/BuiltInsForStringsMisc.java
----------------------------------------------------------------------
diff --git a/freemarker-core/src/main/java/org/apache/freemarker/core/BuiltInsForStringsMisc.java b/freemarker-core/src/main/java/org/apache/freemarker/core/BuiltInsForStringsMisc.java
index d2e5f48..6280c68 100644
--- a/freemarker-core/src/main/java/org/apache/freemarker/core/BuiltInsForStringsMisc.java
+++ b/freemarker-core/src/main/java/org/apache/freemarker/core/BuiltInsForStringsMisc.java
@@ -29,7 +29,6 @@ import org.apache.freemarker.core.model.TemplateBooleanModel;
 import org.apache.freemarker.core.model.TemplateDirectiveModel;
 import org.apache.freemarker.core.model.TemplateFunctionModel;
 import org.apache.freemarker.core.model.TemplateModel;
-import org.apache.freemarker.core.model.TemplateModelException;
 import org.apache.freemarker.core.model.TemplateScalarModel;
 import org.apache.freemarker.core.model.TemplateSequenceModel;
 import org.apache.freemarker.core.model.impl.BeanModel;
@@ -208,7 +207,7 @@ class BuiltInsForStringsMisc {
                         env.setFastInvalidReferenceExceptions(lastFIRE);
                     }
                 } catch (Exception e) {
-                    throw new _TemplateModelException(e,
+                    throw new TemplateException(e,
                             "Template created with \"?", key, "\" has stopped with this error:\n\n",
                             MessageUtils.EMBEDDED_MESSAGE_BEGIN,
                             new _DelayedGetMessage(e),
@@ -276,14 +275,14 @@ class BuiltInsForStringsMisc {
 
             @Override
             public TemplateModel execute(TemplateModel[] args, CallPlace callPlace, Environment env)
-                    throws TemplateModelException {
+                    throws TemplateException {
                 ObjectWrapper ow = env.getObjectWrapper();
                 if (ow instanceof DefaultObjectWrapper) {
                     return ow.wrap(((DefaultObjectWrapper) ow).newInstance(cl, args, callPlace));
                 }
 
                 if (args.length != 0) {
-                    throw new TemplateModelException(
+                    throw new TemplateException(
                             "className?new(args) only supports 0 arguments in the current configuration, because "
                             + " the objectWrapper setting value is not a "
                             + DefaultObjectWrapper.class.getName() +
@@ -292,7 +291,7 @@ class BuiltInsForStringsMisc {
                 try {
                     return ow.wrap(cl.newInstance());
                 } catch (Exception e) {
-                    throw new TemplateModelException("Failed to instantiate "
+                    throw new TemplateException("Failed to instantiate "
                             + cl.getName() + " with its parameterless constructor; see cause exception", e);
                 }
             }

http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/d73da6da/freemarker-core/src/main/java/org/apache/freemarker/core/BuiltInsForStringsRegexp.java
----------------------------------------------------------------------
diff --git a/freemarker-core/src/main/java/org/apache/freemarker/core/BuiltInsForStringsRegexp.java b/freemarker-core/src/main/java/org/apache/freemarker/core/BuiltInsForStringsRegexp.java
index 15ea886..d885845 100644
--- a/freemarker-core/src/main/java/org/apache/freemarker/core/BuiltInsForStringsRegexp.java
+++ b/freemarker-core/src/main/java/org/apache/freemarker/core/BuiltInsForStringsRegexp.java
@@ -30,7 +30,6 @@ import org.apache.freemarker.core.model.TemplateBooleanModel;
 import org.apache.freemarker.core.model.TemplateCollectionModel;
 import org.apache.freemarker.core.model.TemplateFunctionModel;
 import org.apache.freemarker.core.model.TemplateModel;
-import org.apache.freemarker.core.model.TemplateModelException;
 import org.apache.freemarker.core.model.TemplateModelIterator;
 import org.apache.freemarker.core.model.TemplateScalarModel;
 import org.apache.freemarker.core.model.TemplateSequenceModel;
@@ -69,7 +68,7 @@ class BuiltInsForStringsRegexp {
             
             String matchString;
             
-            MatcherBuilder(String matchString) throws TemplateModelException {
+            MatcherBuilder(String matchString) throws TemplateException {
                 this.matchString = matchString;
             }
 
@@ -97,7 +96,7 @@ class BuiltInsForStringsRegexp {
         }
         
         @Override
-        TemplateModel calculateResult(String s, Environment env) throws TemplateModelException {
+        TemplateModel calculateResult(String s, Environment env) throws TemplateException {
             return new MatcherBuilder(s);
         }
         
@@ -145,7 +144,7 @@ class BuiltInsForStringsRegexp {
         }
         
         @Override
-        TemplateModel calculateResult(String s, Environment env) throws TemplateModelException {
+        TemplateModel calculateResult(String s, Environment env) throws TemplateException {
             return new ReplaceMethod(s);
         }
         
@@ -189,7 +188,7 @@ class BuiltInsForStringsRegexp {
         }
         
         @Override
-        public TemplateModel get(int i) throws TemplateModelException {
+        public TemplateModel get(int i) throws TemplateException {
             ArrayList matchingInputParts = this.matchingInputParts;
             if (matchingInputParts == null) {
                 matchingInputParts = getMatchingInputPartsAndStoreResults();
@@ -216,7 +215,7 @@ class BuiltInsForStringsRegexp {
                 entireInputMatchGroups = new TemplateSequenceModel() {
                     
                     @Override
-                    public TemplateModel get(int i) throws TemplateModelException {
+                    public TemplateModel get(int i) throws TemplateException {
                         try {
                             // Avoid IndexOutOfBoundsException:
                             if (i > firedEntireInputMatcher.groupCount()) {
@@ -225,16 +224,16 @@ class BuiltInsForStringsRegexp {
 
                             return new SimpleScalar(firedEntireInputMatcher.group(i));
                         } catch (Exception e) {
-                            throw new TemplateModelException("Failed to read match group", e);
+                            throw new TemplateException("Failed to read regular expression match group", e);
                         }
                     }
                     
                     @Override
-                    public int size() throws TemplateModelException {
+                    public int size() throws TemplateException {
                         try {
                             return firedEntireInputMatcher.groupCount() + 1;
                         } catch (Exception e) {
-                            throw new TemplateModelException("Failed to get match group count", e);
+                            throw new TemplateException("Failed to get regular expression match group count", e);
                         }
                     }
                     
@@ -244,7 +243,7 @@ class BuiltInsForStringsRegexp {
             return entireInputMatchGroups;
         }
         
-        private ArrayList getMatchingInputPartsAndStoreResults() throws TemplateModelException {
+        private ArrayList getMatchingInputPartsAndStoreResults() throws TemplateException {
             ArrayList matchingInputParts = new ArrayList();
             
             Matcher matcher = pattern.matcher(input);
@@ -285,10 +284,12 @@ class BuiltInsForStringsRegexp {
                     }
                     
                     @Override
-                    public TemplateModel next() throws TemplateModelException {
+                    public TemplateModel next() throws TemplateException {
                         final ArrayList matchingInputParts = RegexMatchModel.this.matchingInputParts;
                         if (matchingInputParts == null) {
-                            if (!hasFindInfo) throw new TemplateModelException("There were no more matches");
+                            if (!hasFindInfo) {
+                                throw new TemplateException("There were no more regular expression matches");
+                            }
                             MatchWithGroups result = new MatchWithGroups(input, matcher);
                             nextIdx++;
                             hasFindInfo = matcher.find();
@@ -297,7 +298,7 @@ class BuiltInsForStringsRegexp {
                             try {
                                 return (TemplateModel) matchingInputParts.get(nextIdx++);
                             } catch (IndexOutOfBoundsException e) {
-                                throw new TemplateModelException("There were no more matches", e);
+                                throw new TemplateException("There were no more regular expression matches", e);
                             }
                         }
                     }
@@ -314,11 +315,11 @@ class BuiltInsForStringsRegexp {
                     }
                     
                     @Override
-                    public TemplateModel next() throws TemplateModelException {
+                    public TemplateModel next() throws TemplateException {
                         try {
                             return (TemplateModel) matchingInputParts.get(nextIdx++);
                         } catch (IndexOutOfBoundsException e) {
-                            throw new TemplateModelException("There were no more matches", e);
+                            throw new TemplateException("There were no more regular expression matches", e);
                         }
                     }
                 };
@@ -326,7 +327,7 @@ class BuiltInsForStringsRegexp {
         }
         
         @Override
-        public int size() throws TemplateModelException {
+        public int size() throws TemplateException {
             ArrayList matchingInputParts = this.matchingInputParts;
             if (matchingInputParts == null) {
                 matchingInputParts = getMatchingInputPartsAndStoreResults();

http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/d73da6da/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 e817c1c..9f4d04b 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
@@ -47,9 +47,9 @@ import java.util.concurrent.ConcurrentHashMap;
 import org.apache.freemarker.core.arithmetic.ArithmeticEngine;
 import org.apache.freemarker.core.arithmetic.impl.BigDecimalArithmeticEngine;
 import org.apache.freemarker.core.model.ObjectWrapper;
+import org.apache.freemarker.core.model.ObjectWrappingException;
 import org.apache.freemarker.core.model.TemplateMarkupOutputModel;
 import org.apache.freemarker.core.model.TemplateModel;
-import org.apache.freemarker.core.model.TemplateModelException;
 import org.apache.freemarker.core.model.impl.DefaultObjectWrapper;
 import org.apache.freemarker.core.model.impl.RestrictedObjectWrapper;
 import org.apache.freemarker.core.outputformat.MarkupOutputFormat;
@@ -348,7 +348,7 @@ public final class Configuration implements TopLevelConfiguration, CustomStateSc
             for (Entry<String, Object> ent : sharedVariables.entrySet()) {
                 try {
                     wrappedSharedVariables.put(ent.getKey(), objectWrapper.wrap(ent.getValue()));
-                } catch (TemplateModelException e) {
+                } catch (ObjectWrappingException e) {
                     throw new InvalidSettingValueException(
                             ExtendableBuilder.SHARED_VARIABLES_KEY, null, false,
                             "Failed to wrap shared variable " + _StringUtils.jQuote(ent.getKey()),

http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/d73da6da/freemarker-core/src/main/java/org/apache/freemarker/core/Environment.java
----------------------------------------------------------------------
diff --git a/freemarker-core/src/main/java/org/apache/freemarker/core/Environment.java b/freemarker-core/src/main/java/org/apache/freemarker/core/Environment.java
index 7e7703d..e899ab2 100644
--- a/freemarker-core/src/main/java/org/apache/freemarker/core/Environment.java
+++ b/freemarker-core/src/main/java/org/apache/freemarker/core/Environment.java
@@ -55,7 +55,6 @@ import org.apache.freemarker.core.model.TemplateFunctionModel;
 import org.apache.freemarker.core.model.TemplateHashModel;
 import org.apache.freemarker.core.model.TemplateHashModelEx;
 import org.apache.freemarker.core.model.TemplateModel;
-import org.apache.freemarker.core.model.TemplateModelException;
 import org.apache.freemarker.core.model.TemplateModelIterator;
 import org.apache.freemarker.core.model.TemplateModelWithOriginName;
 import org.apache.freemarker.core.model.TemplateNodeModel;
@@ -443,13 +442,13 @@ public final class Environment extends MutableProcessingConfiguration<Environmen
         } else {
             pushLocalContext(new LocalContext() {
                 @Override
-                public TemplateModel getLocalVariable(String name) throws TemplateModelException {
+                public TemplateModel getLocalVariable(String name) throws TemplateException {
                     int index = nestedContentParamNames.get(name);
                     return index != -1 ? nestedContentParamValues[index] : null;
                 }
 
                 @Override
-                public Collection<String> getLocalVariableNames() throws TemplateModelException {
+                public Collection<String> getLocalVariableNames() throws TemplateException {
                     return nestedContentParamNames.getKeys();
                 }
             });
@@ -624,7 +623,7 @@ public final class Environment extends MutableProcessingConfiguration<Environmen
 
     private Object[] noNodeHandlerDefinedDescription(
             TemplateNodeModel node, String ns, String nodeType)
-                    throws TemplateModelException {
+                    throws TemplateException {
         String nsPrefix;
         if (ns != null) {
             if (ns.length() > 0) {
@@ -666,8 +665,7 @@ public final class Environment extends MutableProcessingConfiguration<Environmen
         if (node == null) {
             node = getCurrentVisitorNode();
             if (node == null) {
-                throw new TemplateModelException(
-                        "The target node of recursion is missing or null.");
+                throw new TemplateException("The target node of recursion is missing or null.");
             }
         }
         TemplateSequenceModel children = node.getChildNodes();
@@ -1092,9 +1090,9 @@ public final class Environment extends MutableProcessingConfiguration<Environmen
      * @param exp
      *            The blamed expression if an error occurs; it's only needed for better error messages
      */
-    String formatNumberToPlainText(TemplateNumberModel number, ASTExpression exp, boolean useTempModelExc)
+    String formatNumberToPlainText(TemplateNumberModel number, ASTExpression exp)
             throws TemplateException {
-        return formatNumberToPlainText(number, getTemplateNumberFormat(exp, useTempModelExc), exp, useTempModelExc);
+        return formatNumberToPlainText(number, getTemplateNumberFormat(exp), exp);
     }
 
     /**
@@ -1104,13 +1102,12 @@ public final class Environment extends MutableProcessingConfiguration<Environmen
      *            The blamed expression if an error occurs; it's only needed for better error messages
      */
     String formatNumberToPlainText(
-            TemplateNumberModel number, TemplateNumberFormat format, ASTExpression exp,
-            boolean useTempModelExc)
+            TemplateNumberModel number, TemplateNumberFormat format, ASTExpression exp)
             throws TemplateException {
         try {
             return _EvalUtils.assertFormatResultNotNull(format.formatToPlainText(number));
         } catch (TemplateValueFormatException e) {
-            throw MessageUtils.newCantFormatNumberException(format, exp, e, useTempModelExc);
+            throw MessageUtils.newCantFormatNumberException(format, exp, e);
         }
     }
 
@@ -1174,7 +1171,7 @@ public final class Environment extends MutableProcessingConfiguration<Environmen
     /**
      * Convenience wrapper around {@link #getTemplateNumberFormat()} to be called during expression evaluation.
      */
-    TemplateNumberFormat getTemplateNumberFormat(ASTExpression exp, boolean useTempModelExc) throws TemplateException {
+    TemplateNumberFormat getTemplateNumberFormat(ASTExpression exp) throws TemplateException {
         TemplateNumberFormat format;
         try {
             format = getTemplateNumberFormat();
@@ -1183,8 +1180,7 @@ public final class Environment extends MutableProcessingConfiguration<Environmen
                     "Failed to get number format object for the current number format string, ",
                     new _DelayedJQuote(getNumberFormat()), ": ", e.getMessage())
                     .blame(exp); 
-            throw useTempModelExc
-                    ? new _TemplateModelException(e, this, desc) : new TemplateException(e, this, desc);
+            throw new TemplateException(e, this, desc);
         }
         return format;
     }
@@ -1195,7 +1191,7 @@ public final class Environment extends MutableProcessingConfiguration<Environmen
      * @param exp
      *            The blamed expression if an error occurs; it's only needed for better error messages
      */
-    TemplateNumberFormat getTemplateNumberFormat(String formatString, ASTExpression exp, boolean useTempModelExc)
+    TemplateNumberFormat getTemplateNumberFormat(String formatString, ASTExpression exp)
             throws TemplateException {
         TemplateNumberFormat format;
         try {
@@ -1205,8 +1201,7 @@ public final class Environment extends MutableProcessingConfiguration<Environmen
                     "Failed to get number format object for the ", new _DelayedJQuote(formatString),
                     " number format string: ", e.getMessage())
                     .blame(exp);
-            throw useTempModelExc
-                    ? new _TemplateModelException(e, this, desc) : new TemplateException(e, this, desc);
+            throw new TemplateException(e, this, desc);
         }
         return format;
     }
@@ -1379,14 +1374,13 @@ public final class Environment extends MutableProcessingConfiguration<Environmen
      * @param tdmSourceExpr
      *            The blamed expression if an error occurs; only used for error messages.
      */
-    String formatDateToPlainText(TemplateDateModel tdm, ASTExpression tdmSourceExpr,
-            boolean useTempModelExc) throws TemplateException {
-        TemplateDateFormat format = getTemplateDateFormat(tdm, tdmSourceExpr, useTempModelExc);
+    String formatDateToPlainText(TemplateDateModel tdm, ASTExpression tdmSourceExpr) throws TemplateException {
+        TemplateDateFormat format = getTemplateDateFormat(tdm, tdmSourceExpr);
         
         try {
             return _EvalUtils.assertFormatResultNotNull(format.formatToPlainText(tdm));
         } catch (TemplateValueFormatException e) {
-            throw MessageUtils.newCantFormatDateException(format, tdmSourceExpr, e, useTempModelExc);
+            throw MessageUtils.newCantFormatDateException(format, tdmSourceExpr, e);
         }
     }
 
@@ -1397,19 +1391,17 @@ public final class Environment extends MutableProcessingConfiguration<Environmen
      *            The blamed expression if an error occurs; only used for error messages.
      */
     String formatDateToPlainText(TemplateDateModel tdm, String formatString,
-            ASTExpression blamedDateSourceExp, ASTExpression blamedFormatterExp,
-            boolean useTempModelExc) throws TemplateException {
+            ASTExpression blamedDateSourceExp, ASTExpression blamedFormatterExp) throws TemplateException {
         Date date = _EvalUtils.modelToDate(tdm, blamedDateSourceExp);
         
         TemplateDateFormat format = getTemplateDateFormat(
                 formatString, tdm.getDateType(), date.getClass(),
-                blamedDateSourceExp, blamedFormatterExp,
-                useTempModelExc);
+                blamedDateSourceExp, blamedFormatterExp);
         
         try {
             return _EvalUtils.assertFormatResultNotNull(format.formatToPlainText(tdm));
         } catch (TemplateValueFormatException e) {
-            throw MessageUtils.newCantFormatDateException(format, blamedDateSourceExp, e, useTempModelExc);
+            throw MessageUtils.newCantFormatDateException(format, blamedDateSourceExp, e);
         }
     }
 
@@ -1569,20 +1561,19 @@ public final class Environment extends MutableProcessingConfiguration<Environmen
         return getTemplateDateFormatWithoutCache(formatString, dateType, locale, timeZone, zonelessInput);
     }
     
-    TemplateDateFormat getTemplateDateFormat(TemplateDateModel tdm, ASTExpression tdmSourceExpr, boolean useTempModelExc)
+    TemplateDateFormat getTemplateDateFormat(TemplateDateModel tdm, ASTExpression tdmSourceExpr)
             throws TemplateException {
         Date date = _EvalUtils.modelToDate(tdm, tdmSourceExpr);
         
         return getTemplateDateFormat(
-                tdm.getDateType(), date.getClass(), tdmSourceExpr,
-                useTempModelExc);
+                tdm.getDateType(), date.getClass(), tdmSourceExpr);
     }
 
     /**
      * Same as {@link #getTemplateDateFormat(int, Class)}, but translates the exceptions to {@link TemplateException}-s.
      */
     TemplateDateFormat getTemplateDateFormat(
-            int dateType, Class<? extends Date> dateClass, ASTExpression blamedDateSourceExp, boolean useTempModelExc)
+            int dateType, Class<? extends Date> dateClass, ASTExpression blamedDateSourceExp)
                     throws TemplateException {
         try {
             return getTemplateDateFormat(dateType, dateClass);
@@ -1614,7 +1605,7 @@ public final class Environment extends MutableProcessingConfiguration<Environmen
                     "\" FreeMarker configuration setting is a malformed date/time/dateTime format string: ",
                     new _DelayedJQuote(settingValue), ". Reason given: ",
                     e.getMessage());                    
-            throw useTempModelExc ? new _TemplateModelException(e, desc) : new TemplateException(e, desc);
+            throw new TemplateException(e, desc);
         }
     }
 
@@ -1624,8 +1615,7 @@ public final class Environment extends MutableProcessingConfiguration<Environmen
      */
     TemplateDateFormat getTemplateDateFormat(
             String formatString, int dateType, Class<? extends Date> dateClass,
-            ASTExpression blamedDateSourceExp, ASTExpression blamedFormatterExp,
-            boolean useTempModelExc)
+            ASTExpression blamedDateSourceExp, ASTExpression blamedFormatterExp)
                     throws TemplateException {
         try {
             return getTemplateDateFormat(formatString, dateType, dateClass);
@@ -1637,7 +1627,7 @@ public final class Environment extends MutableProcessingConfiguration<Environmen
                     new _DelayedJQuote(formatString), ". Reason given: ",
                     e.getMessage())
                     .blame(blamedFormatterExp);
-            throw useTempModelExc ? new _TemplateModelException(e, desc) : new TemplateException(e, desc);
+            throw new TemplateException(e, desc);
         }
     }
 
@@ -1854,7 +1844,7 @@ public final class Environment extends MutableProcessingConfiguration<Environmen
      * according to our terminology.)
      */
     // TODO [FM3] Don't return nested content params anymore (see JavaDoc)
-    public TemplateModel getLocalVariable(String name) throws TemplateModelException {
+    public TemplateModel getLocalVariable(String name) throws TemplateException {
         if (localContextStack != null) {
             for (int i = localContextStack.size() - 1; i >= 0; i--) {
                 LocalContext lc = localContextStack.get(i);
@@ -1884,7 +1874,7 @@ public final class Environment extends MutableProcessingConfiguration<Environmen
      * </li>
      * </ol>
      */
-    public TemplateModel getVariable(String name) throws TemplateModelException {
+    public TemplateModel getVariable(String name) throws TemplateException {
         TemplateModel result = getLocalVariable(name);
         if (result == null) {
             result = currentNamespace.get(name);
@@ -1900,7 +1890,7 @@ public final class Environment extends MutableProcessingConfiguration<Environmen
      * <code>.globals.<i>name</i></code>. This will first look at variables that were assigned globally via: &lt;#global
      * ...&gt; and then at the data model exposed to the template.
      */
-    public TemplateModel getGlobalVariable(String name) throws TemplateModelException {
+    public TemplateModel getGlobalVariable(String name) throws TemplateException {
         TemplateModel result = globalNamespace.get(name);
         if (result == null) {
             result = rootDataModel.get(name);
@@ -1956,7 +1946,7 @@ public final class Environment extends MutableProcessingConfiguration<Environmen
      * object on each call that is completely disconnected from the Environment. That is, modifying the set will have no
      * effect on the Environment object.
      */
-    public Set getKnownVariableNames() throws TemplateModelException {
+    public Set getKnownVariableNames() throws TemplateException {
         // shared vars.
         Set set = configuration.getSharedVariables().keySet();
 
@@ -2210,7 +2200,7 @@ public final class Environment extends MutableProcessingConfiguration<Environmen
             }
 
             @Override
-            public TemplateModel get(String key) throws TemplateModelException {
+            public TemplateModel get(String key) throws TemplateException {
                 TemplateModel value = rootDataModel.get(key);
                 if (value == null) {
                     value = configuration.getWrappedSharedVariable(key);
@@ -2223,12 +2213,12 @@ public final class Environment extends MutableProcessingConfiguration<Environmen
             return new TemplateHashModelEx() {
 
                 @Override
-                public boolean isEmpty() throws TemplateModelException {
+                public boolean isEmpty() throws TemplateException {
                     return result.isEmpty();
                 }
 
                 @Override
-                public TemplateModel get(String key) throws TemplateModelException {
+                public TemplateModel get(String key) throws TemplateException {
                     return result.get(key);
                 }
 
@@ -2236,17 +2226,17 @@ public final class Environment extends MutableProcessingConfiguration<Environmen
                 // configuration shared variables even though
                 // the hash will return them, if only for BWC reasons
                 @Override
-                public TemplateCollectionModel values() throws TemplateModelException {
+                public TemplateCollectionModel values() throws TemplateException {
                     return ((TemplateHashModelEx) rootDataModel).values();
                 }
 
                 @Override
-                public TemplateCollectionModel keys() throws TemplateModelException {
+                public TemplateCollectionModel keys() throws TemplateException {
                     return ((TemplateHashModelEx) rootDataModel).keys();
                 }
 
                 @Override
-                public int size() throws TemplateModelException {
+                public int size() throws TemplateException {
                     return ((TemplateHashModelEx) rootDataModel).size();
                 }
             };
@@ -2268,7 +2258,7 @@ public final class Environment extends MutableProcessingConfiguration<Environmen
             }
 
             @Override
-            public TemplateModel get(String key) throws TemplateModelException {
+            public TemplateModel get(String key) throws TemplateException {
                 TemplateModel result = globalNamespace.get(key);
                 if (result == null) {
                     result = rootDataModel.get(key);
@@ -2760,10 +2750,10 @@ public final class Environment extends MutableProcessingConfiguration<Environmen
             customLookupCondition = getIncludedTemplateCustomLookupCondition();
         }
 
-        private void ensureInitializedTME() throws TemplateModelException {
+        private void ensureInitializedTME() throws TemplateException {
             if (status != InitializationStatus.INITIALIZED && status != InitializationStatus.INITIALIZING) {
                 if (status == InitializationStatus.FAILED) {
-                    throw new TemplateModelException(
+                    throw new TemplateException(
                             "Lazy initialization of the imported namespace for "
                             + _StringUtils.jQuote(templateName)
                             + " has already failed earlier; won't retry it.");
@@ -2774,7 +2764,7 @@ public final class Environment extends MutableProcessingConfiguration<Environmen
                     status = InitializationStatus.INITIALIZED;
                 } catch (Exception e) {
                     // [FM3] Rethrow TemplateException-s as is
-                    throw new TemplateModelException(
+                    throw new TemplateException(
                             "Lazy initialization of the imported namespace for "
                             + _StringUtils.jQuote(templateName)
                             + " has failed; see cause exception", e);
@@ -2789,7 +2779,7 @@ public final class Environment extends MutableProcessingConfiguration<Environmen
         private void ensureInitializedRTE() {
             try {
                 ensureInitializedTME();
-            } catch (TemplateModelException e) {
+            } catch (TemplateException e) {
                 throw new RuntimeException(e.getMessage(), e.getCause());
             }
         }
@@ -2830,7 +2820,7 @@ public final class Environment extends MutableProcessingConfiguration<Environmen
         }
 
         @Override
-        public TemplateModel get(String key) throws TemplateModelException {
+        public TemplateModel get(String key) throws TemplateException {
             ensureInitializedTME();
             return super.get(key);
         }

http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/d73da6da/freemarker-core/src/main/java/org/apache/freemarker/core/ListableRightUnboundedRangeModel.java
----------------------------------------------------------------------
diff --git a/freemarker-core/src/main/java/org/apache/freemarker/core/ListableRightUnboundedRangeModel.java b/freemarker-core/src/main/java/org/apache/freemarker/core/ListableRightUnboundedRangeModel.java
index 935bce9..0b7e94e 100644
--- a/freemarker-core/src/main/java/org/apache/freemarker/core/ListableRightUnboundedRangeModel.java
+++ b/freemarker-core/src/main/java/org/apache/freemarker/core/ListableRightUnboundedRangeModel.java
@@ -23,7 +23,6 @@ import java.math.BigInteger;
 
 import org.apache.freemarker.core.model.TemplateCollectionModel;
 import org.apache.freemarker.core.model.TemplateModel;
-import org.apache.freemarker.core.model.TemplateModelException;
 import org.apache.freemarker.core.model.TemplateModelIterator;
 import org.apache.freemarker.core.model.impl.SimpleNumber;
 
@@ -37,12 +36,12 @@ final class ListableRightUnboundedRangeModel extends RightUnboundedRangeModel im
     }
 
     @Override
-    public int size() throws TemplateModelException {
+    public int size() throws TemplateException {
         return Integer.MAX_VALUE;
     }
 
     @Override
-    public TemplateModelIterator iterator() throws TemplateModelException {
+    public TemplateModelIterator iterator() throws TemplateException {
         return new TemplateModelIterator() {
             boolean needInc;
             int nextType = 1;
@@ -51,7 +50,7 @@ final class ListableRightUnboundedRangeModel extends RightUnboundedRangeModel im
             BigInteger nextBigInteger;
 
             @Override
-            public TemplateModel next() throws TemplateModelException {
+            public TemplateModel next() throws TemplateException {
                 if (needInc) {
                     switch (nextType) {
                     case 1:
@@ -84,7 +83,7 @@ final class ListableRightUnboundedRangeModel extends RightUnboundedRangeModel im
             }
 
             @Override
-            public boolean hasNext() throws TemplateModelException {
+            public boolean hasNext() throws TemplateException {
                 return true;
             }
             

http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/d73da6da/freemarker-core/src/main/java/org/apache/freemarker/core/LocalContext.java
----------------------------------------------------------------------
diff --git a/freemarker-core/src/main/java/org/apache/freemarker/core/LocalContext.java b/freemarker-core/src/main/java/org/apache/freemarker/core/LocalContext.java
index 59d867d..551ce25 100644
--- a/freemarker-core/src/main/java/org/apache/freemarker/core/LocalContext.java
+++ b/freemarker-core/src/main/java/org/apache/freemarker/core/LocalContext.java
@@ -22,7 +22,6 @@ package org.apache.freemarker.core;
 import java.util.Collection;
 
 import org.apache.freemarker.core.model.TemplateModel;
-import org.apache.freemarker.core.model.TemplateModelException;
 
 /**
   * An interface that represents a local context. This is used as the abstraction for  
@@ -30,6 +29,6 @@ import org.apache.freemarker.core.model.TemplateModelException;
   * a macro.
   */
 public interface LocalContext {
-    TemplateModel getLocalVariable(String name) throws TemplateModelException;
-    Collection<String> getLocalVariableNames() throws TemplateModelException;
+    TemplateModel getLocalVariable(String name) throws TemplateException;
+    Collection<String> getLocalVariableNames() throws TemplateException;
 }

http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/d73da6da/freemarker-core/src/main/java/org/apache/freemarker/core/MessageUtils.java
----------------------------------------------------------------------
diff --git a/freemarker-core/src/main/java/org/apache/freemarker/core/MessageUtils.java b/freemarker-core/src/main/java/org/apache/freemarker/core/MessageUtils.java
index d1db6e6..21f7876 100644
--- a/freemarker-core/src/main/java/org/apache/freemarker/core/MessageUtils.java
+++ b/freemarker-core/src/main/java/org/apache/freemarker/core/MessageUtils.java
@@ -24,7 +24,6 @@ import org.apache.freemarker.core.model.TemplateCollectionModel;
 import org.apache.freemarker.core.model.TemplateDateModel;
 import org.apache.freemarker.core.model.TemplateMarkupOutputModel;
 import org.apache.freemarker.core.model.TemplateModel;
-import org.apache.freemarker.core.model.TemplateModelException;
 import org.apache.freemarker.core.model.TemplateNumberModel;
 import org.apache.freemarker.core.model.TemplateScalarModel;
 import org.apache.freemarker.core.model.TemplateSequenceModel;
@@ -208,34 +207,30 @@ class MessageUtils {
                 "Instantiating ", className, " is not allowed in the template for security reasons.");
     }
     
-    static TemplateModelException newCantFormatUnknownTypeDateException(
+    static TemplateException newCantFormatUnknownTypeDateException(
             ASTExpression dateSourceExpr, UnknownDateTypeFormattingUnsupportedException cause) {
-        return new _TemplateModelException(cause, null, new _ErrorDescriptionBuilder(
+        return new TemplateException(cause, null, new _ErrorDescriptionBuilder(
                 UNKNOWN_DATE_TO_STRING_ERROR_MESSAGE)
                 .blame(dateSourceExpr)
                 .tips(UNKNOWN_DATE_TO_STRING_TIPS));
     }
 
     static TemplateException newCantFormatDateException(TemplateDateFormat format, ASTExpression dataSrcExp,
-                                                        TemplateValueFormatException e, boolean useTempModelExc) {
+                                                        TemplateValueFormatException e) {
         _ErrorDescriptionBuilder desc = new _ErrorDescriptionBuilder(
                 "Failed to format date/time/dateTime with format ", new _DelayedJQuote(format.getDescription()), ": ",
                 e.getMessage())
                 .blame(dataSrcExp); 
-        return useTempModelExc
-                ? new _TemplateModelException(e, null, desc)
-                : new TemplateException(e, null, desc);
+        return new TemplateException(e, null, desc);
     }
     
     static TemplateException newCantFormatNumberException(TemplateNumberFormat format, ASTExpression dataSrcExp,
-                                                          TemplateValueFormatException e, boolean useTempModelExc) {
+                                                          TemplateValueFormatException e) {
         _ErrorDescriptionBuilder desc = new _ErrorDescriptionBuilder(
                 "Failed to format number with format ", new _DelayedJQuote(format.getDescription()), ": ",
                 e.getMessage())
                 .blame(dataSrcExp); 
-        return useTempModelExc
-                ? new _TemplateModelException(e, null, desc)
-                : new TemplateException(e, null, desc);
+        return new TemplateException(e, null, desc);
     }
     
     /**

http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/d73da6da/freemarker-core/src/main/java/org/apache/freemarker/core/NativeCollectionEx.java
----------------------------------------------------------------------
diff --git a/freemarker-core/src/main/java/org/apache/freemarker/core/NativeCollectionEx.java b/freemarker-core/src/main/java/org/apache/freemarker/core/NativeCollectionEx.java
index 5afa98a..119cae5 100644
--- a/freemarker-core/src/main/java/org/apache/freemarker/core/NativeCollectionEx.java
+++ b/freemarker-core/src/main/java/org/apache/freemarker/core/NativeCollectionEx.java
@@ -25,7 +25,6 @@ import java.util.Iterator;
 import org.apache.freemarker.core.model.ObjectWrapper;
 import org.apache.freemarker.core.model.TemplateCollectionModelEx;
 import org.apache.freemarker.core.model.TemplateModel;
-import org.apache.freemarker.core.model.TemplateModelException;
 import org.apache.freemarker.core.model.TemplateModelIterator;
 
 /**
@@ -50,15 +49,15 @@ class NativeCollectionEx implements TemplateCollectionModelEx {
     }
 
     @Override
-    public TemplateModelIterator iterator() throws TemplateModelException {
+    public TemplateModelIterator iterator() throws TemplateException {
         return new TemplateModelIterator() {
 
             private final Iterator<TemplateModel> iterator = collection.iterator();
 
             @Override
-            public TemplateModel next() throws TemplateModelException {
+            public TemplateModel next() throws TemplateException {
                 if (!iterator.hasNext()) {
-                    throw new TemplateModelException("The collection has no more items.");
+                    throw new TemplateException("The collection has no more items.");
                 }
 
                 return iterator.next();

http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/d73da6da/freemarker-core/src/main/java/org/apache/freemarker/core/NativeHashEx2.java
----------------------------------------------------------------------
diff --git a/freemarker-core/src/main/java/org/apache/freemarker/core/NativeHashEx2.java b/freemarker-core/src/main/java/org/apache/freemarker/core/NativeHashEx2.java
index 2850255..526bf6b 100644
--- a/freemarker-core/src/main/java/org/apache/freemarker/core/NativeHashEx2.java
+++ b/freemarker-core/src/main/java/org/apache/freemarker/core/NativeHashEx2.java
@@ -28,7 +28,6 @@ import org.apache.freemarker.core.model.ObjectWrapper;
 import org.apache.freemarker.core.model.TemplateCollectionModel;
 import org.apache.freemarker.core.model.TemplateHashModelEx2;
 import org.apache.freemarker.core.model.TemplateModel;
-import org.apache.freemarker.core.model.TemplateModelException;
 import org.apache.freemarker.core.model.impl.SimpleScalar;
 
 /**
@@ -46,42 +45,42 @@ class NativeHashEx2 implements TemplateHashModelEx2, Serializable {
     }
 
     @Override
-    public int size() throws TemplateModelException {
+    public int size() throws TemplateException {
         return map.size();
     }
 
     @Override
-    public TemplateModel get(String key) throws TemplateModelException {
+    public TemplateModel get(String key) throws TemplateException {
         return map.get(key);
     }
 
     @Override
-    public boolean isEmpty() throws TemplateModelException {
+    public boolean isEmpty() throws TemplateException {
         return map.isEmpty();
     }
 
     @Override
-    public KeyValuePairIterator keyValuePairIterator() throws TemplateModelException {
+    public KeyValuePairIterator keyValuePairIterator() throws TemplateException {
         return new KeyValuePairIterator() {
             private final Iterator<Map.Entry<String, TemplateModel>> entrySetIterator = map.entrySet().iterator();
 
             @Override
-            public boolean hasNext() throws TemplateModelException {
+            public boolean hasNext() throws TemplateException {
                 return entrySetIterator.hasNext();
             }
 
             @Override
-            public KeyValuePair next() throws TemplateModelException {
+            public KeyValuePair next() throws TemplateException {
                 return new KeyValuePair() {
                     private final Map.Entry<String, TemplateModel> entry = entrySetIterator.next();
 
                     @Override
-                    public TemplateModel getKey() throws TemplateModelException {
+                    public TemplateModel getKey() throws TemplateException {
                         return new SimpleScalar(entry.getKey());
                     }
 
                     @Override
-                    public TemplateModel getValue() throws TemplateModelException {
+                    public TemplateModel getValue() throws TemplateException {
                         return entry.getValue();
                     }
                 };
@@ -90,12 +89,12 @@ class NativeHashEx2 implements TemplateHashModelEx2, Serializable {
     }
 
     @Override
-    public TemplateCollectionModel keys() throws TemplateModelException {
+    public TemplateCollectionModel keys() throws TemplateException {
         return new NativeStringCollectionCollectionEx(map.keySet());
     }
 
     @Override
-    public TemplateCollectionModel values() throws TemplateModelException {
+    public TemplateCollectionModel values() throws TemplateException {
         return new NativeCollectionEx(map.values());
     }
 

http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/d73da6da/freemarker-core/src/main/java/org/apache/freemarker/core/NativeSequence.java
----------------------------------------------------------------------
diff --git a/freemarker-core/src/main/java/org/apache/freemarker/core/NativeSequence.java b/freemarker-core/src/main/java/org/apache/freemarker/core/NativeSequence.java
index d1b6886..5a43ef6 100644
--- a/freemarker-core/src/main/java/org/apache/freemarker/core/NativeSequence.java
+++ b/freemarker-core/src/main/java/org/apache/freemarker/core/NativeSequence.java
@@ -25,7 +25,6 @@ import java.util.Collection;
 
 import org.apache.freemarker.core.model.ObjectWrapper;
 import org.apache.freemarker.core.model.TemplateModel;
-import org.apache.freemarker.core.model.TemplateModelException;
 import org.apache.freemarker.core.model.TemplateSequenceModel;
 
 /**
@@ -63,12 +62,12 @@ class NativeSequence implements TemplateSequenceModel, Serializable {
     }
 
     @Override
-    public TemplateModel get(int index) throws TemplateModelException {
+    public TemplateModel get(int index) throws TemplateException {
         return items.get(index);
     }
 
     @Override
-    public int size() throws TemplateModelException {
+    public int size() throws TemplateException {
         return items.size();
     }
 }

http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/d73da6da/freemarker-core/src/main/java/org/apache/freemarker/core/NativeStringArraySequence.java
----------------------------------------------------------------------
diff --git a/freemarker-core/src/main/java/org/apache/freemarker/core/NativeStringArraySequence.java b/freemarker-core/src/main/java/org/apache/freemarker/core/NativeStringArraySequence.java
index 96e9899..fedaf66 100644
--- a/freemarker-core/src/main/java/org/apache/freemarker/core/NativeStringArraySequence.java
+++ b/freemarker-core/src/main/java/org/apache/freemarker/core/NativeStringArraySequence.java
@@ -21,7 +21,6 @@ package org.apache.freemarker.core;
 
 import org.apache.freemarker.core.model.ObjectWrapper;
 import org.apache.freemarker.core.model.TemplateModel;
-import org.apache.freemarker.core.model.TemplateModelException;
 import org.apache.freemarker.core.model.TemplateSequenceModel;
 import org.apache.freemarker.core.model.impl.DefaultArrayAdapter;
 import org.apache.freemarker.core.model.impl.SimpleScalar;
@@ -41,12 +40,12 @@ class NativeStringArraySequence implements TemplateSequenceModel {
     }
 
     @Override
-    public TemplateModel get(int index) throws TemplateModelException {
+    public TemplateModel get(int index) throws TemplateException {
         return index < items.length ? new SimpleScalar(items[index]) : null;
     }
 
     @Override
-    public int size() throws TemplateModelException {
+    public int size() throws TemplateException {
         return items.length;
     }
 

http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/d73da6da/freemarker-core/src/main/java/org/apache/freemarker/core/NativeStringCollectionCollectionEx.java
----------------------------------------------------------------------
diff --git a/freemarker-core/src/main/java/org/apache/freemarker/core/NativeStringCollectionCollectionEx.java b/freemarker-core/src/main/java/org/apache/freemarker/core/NativeStringCollectionCollectionEx.java
index b2437e7..cef0e79 100644
--- a/freemarker-core/src/main/java/org/apache/freemarker/core/NativeStringCollectionCollectionEx.java
+++ b/freemarker-core/src/main/java/org/apache/freemarker/core/NativeStringCollectionCollectionEx.java
@@ -25,7 +25,6 @@ import java.util.Iterator;
 import org.apache.freemarker.core.model.ObjectWrapper;
 import org.apache.freemarker.core.model.TemplateCollectionModelEx;
 import org.apache.freemarker.core.model.TemplateModel;
-import org.apache.freemarker.core.model.TemplateModelException;
 import org.apache.freemarker.core.model.TemplateModelIterator;
 import org.apache.freemarker.core.model.impl.DefaultNonListCollectionAdapter;
 import org.apache.freemarker.core.model.impl.SimpleScalar;
@@ -56,15 +55,15 @@ class NativeStringCollectionCollectionEx implements TemplateCollectionModelEx {
     }
 
     @Override
-    public TemplateModelIterator iterator() throws TemplateModelException {
+    public TemplateModelIterator iterator() throws TemplateException {
         return new TemplateModelIterator() {
 
             private final Iterator<String> iterator = collection.iterator();
 
             @Override
-            public TemplateModel next() throws TemplateModelException {
+            public TemplateModel next() throws TemplateException {
                 if (!iterator.hasNext()) {
-                    throw new TemplateModelException("The collection has no more items.");
+                    throw new TemplateException("The collection has no more items.");
                 }
 
                 return new SimpleScalar(iterator.next());

http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/d73da6da/freemarker-core/src/main/java/org/apache/freemarker/core/NativeStringListSequence.java
----------------------------------------------------------------------
diff --git a/freemarker-core/src/main/java/org/apache/freemarker/core/NativeStringListSequence.java b/freemarker-core/src/main/java/org/apache/freemarker/core/NativeStringListSequence.java
index 7846fd3..6adeade 100644
--- a/freemarker-core/src/main/java/org/apache/freemarker/core/NativeStringListSequence.java
+++ b/freemarker-core/src/main/java/org/apache/freemarker/core/NativeStringListSequence.java
@@ -23,7 +23,6 @@ import java.util.List;
 
 import org.apache.freemarker.core.model.ObjectWrapper;
 import org.apache.freemarker.core.model.TemplateModel;
-import org.apache.freemarker.core.model.TemplateModelException;
 import org.apache.freemarker.core.model.TemplateSequenceModel;
 import org.apache.freemarker.core.model.impl.DefaultListAdapter;
 import org.apache.freemarker.core.model.impl.SimpleScalar;
@@ -44,12 +43,12 @@ class NativeStringListSequence implements TemplateSequenceModel {
     }
 
     @Override
-    public TemplateModel get(int index) throws TemplateModelException {
+    public TemplateModel get(int index) throws TemplateException {
         return index < items.size() ? new SimpleScalar(items.get(index)) : null;
     }
 
     @Override
-    public int size() throws TemplateModelException {
+    public int size() throws TemplateException {
         return items.size();
     }
 

http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/d73da6da/freemarker-core/src/main/java/org/apache/freemarker/core/RangeModel.java
----------------------------------------------------------------------
diff --git a/freemarker-core/src/main/java/org/apache/freemarker/core/RangeModel.java b/freemarker-core/src/main/java/org/apache/freemarker/core/RangeModel.java
index 45f9345..512102a 100644
--- a/freemarker-core/src/main/java/org/apache/freemarker/core/RangeModel.java
+++ b/freemarker-core/src/main/java/org/apache/freemarker/core/RangeModel.java
@@ -20,7 +20,6 @@
 package org.apache.freemarker.core;
 
 import org.apache.freemarker.core.model.TemplateModel;
-import org.apache.freemarker.core.model.TemplateModelException;
 import org.apache.freemarker.core.model.TemplateSequenceModel;
 import org.apache.freemarker.core.model.impl.SimpleNumber;
 
@@ -37,9 +36,9 @@ abstract class RangeModel implements TemplateSequenceModel, java.io.Serializable
     }
     
     @Override
-    final public TemplateModel get(int index) throws TemplateModelException {
+    final public TemplateModel get(int index) throws TemplateException {
         if (index < 0 || index >= size()) {
-            throw new _TemplateModelException("Range item index ", Integer.valueOf(index), " is out of bounds.");
+            throw new TemplateException("Range item index ", Integer.valueOf(index), " is out of bounds.");
         }
         long value = begin + getStep() * (long) index;
         return value <= Integer.MAX_VALUE ? new SimpleNumber((int) value) : new SimpleNumber(value);

http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/d73da6da/freemarker-core/src/main/java/org/apache/freemarker/core/RegexpHelper.java
----------------------------------------------------------------------
diff --git a/freemarker-core/src/main/java/org/apache/freemarker/core/RegexpHelper.java b/freemarker-core/src/main/java/org/apache/freemarker/core/RegexpHelper.java
index 37b5fd5..17b58c3 100644
--- a/freemarker-core/src/main/java/org/apache/freemarker/core/RegexpHelper.java
+++ b/freemarker-core/src/main/java/org/apache/freemarker/core/RegexpHelper.java
@@ -22,7 +22,6 @@ package org.apache.freemarker.core;
 import java.util.regex.Pattern;
 import java.util.regex.PatternSyntaxException;
 
-import org.apache.freemarker.core.model.TemplateModelException;
 import org.apache.freemarker.core.templateresolver.impl.MruCacheStorage;
 import org.apache.freemarker.core.util._StringUtils;
 import org.slf4j.Logger;
@@ -64,7 +63,7 @@ final class RegexpHelper {
     private RegexpHelper() { }
 
     static Pattern getPattern(String patternString, int flags)
-    throws TemplateModelException {
+    throws TemplateException {
         PatternCacheKey patternKey = new PatternCacheKey(patternString, flags);
         
         Pattern result;
@@ -79,8 +78,7 @@ final class RegexpHelper {
         try {
             result = Pattern.compile(patternString, flags);
         } catch (PatternSyntaxException e) {
-            throw new _TemplateModelException(e,
-                    "Malformed regular expression: ", new _DelayedGetMessage(e));
+            throw new TemplateException(e, "Malformed regular expression: ", new _DelayedGetMessage(e));
         }
         synchronized (patternCache) {
             patternCache.put(patternKey, result);
@@ -176,12 +174,12 @@ final class RegexpHelper {
         LOG.warn(message);
     }
 
-    static void checkNonRegexpFlags(String biName, long flags) throws _TemplateModelException {
+    static void checkNonRegexpFlags(String biName, long flags) throws TemplateException {
         checkOnlyHasNonRegexpFlags(biName, flags, false);
     }
     
     static void checkOnlyHasNonRegexpFlags(String biName, long flags, boolean strict)
-            throws _TemplateModelException {
+            throws TemplateException {
         if (!strict && !flagWarningsEnabled) return;
         
         String flag; 
@@ -198,7 +196,7 @@ final class RegexpHelper {
         final Object[] msg = { "?", biName ," doesn't support the \"", flag, "\" flag "
                 + "without the \"r\" flag." };
         if (strict) {
-            throw new _TemplateModelException(msg);
+            throw new TemplateException(msg);
         } else {
             // Suppress error for backward compatibility
             logFlagWarning(new _ErrorDescriptionBuilder(msg).toString());

http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/d73da6da/freemarker-core/src/main/java/org/apache/freemarker/core/Template.java
----------------------------------------------------------------------
diff --git a/freemarker-core/src/main/java/org/apache/freemarker/core/Template.java b/freemarker-core/src/main/java/org/apache/freemarker/core/Template.java
index 9384b9e..1354694 100644
--- a/freemarker-core/src/main/java/org/apache/freemarker/core/Template.java
+++ b/freemarker-core/src/main/java/org/apache/freemarker/core/Template.java
@@ -45,6 +45,7 @@ import java.util.concurrent.ConcurrentHashMap;
 import org.apache.freemarker.core.arithmetic.ArithmeticEngine;
 import org.apache.freemarker.core.debug._DebuggerService;
 import org.apache.freemarker.core.model.ObjectWrapper;
+import org.apache.freemarker.core.model.ObjectWrappingException;
 import org.apache.freemarker.core.model.TemplateHashModel;
 import org.apache.freemarker.core.model.TemplateModel;
 import org.apache.freemarker.core.model.TemplateNodeModel;
@@ -411,9 +412,11 @@ public class Template implements ProcessingConfiguration, CustomStateScope {
      *            {@link ProcessingConfiguration#getAutoFlush() autoFlush} to {@code false} to disable this,
      *            {@link Writer#flush()} will be called at the when the template processing was finished.
      *            {@link Writer#close()} is not called. Can't be {@code null}.
-     * 
+     *
      * @throws TemplateException
      *             if an exception occurs during template processing
+     * @throws ObjectWrappingException
+     *             if the {@code dataModel} couldn't be wrapped; note that this extends {@link TemplateException}
      * @throws IOException
      *             if an I/O exception occurs during writing to the writer.
      */
@@ -429,9 +432,6 @@ public class Template implements ProcessingConfiguration, CustomStateScope {
      * typical example of recursive node processing.
      * 
      * @param rootNode The root node for recursive processing or {@code null}.
-     * 
-     * @throws TemplateException if an exception occurs during template processing
-     * @throws IOException if an I/O exception occurs during writing to the writer.
      */
     public void process(Object dataModel, Writer out, ObjectWrapper wrapper, TemplateNodeModel rootNode)
     throws TemplateException, IOException {
@@ -495,9 +495,13 @@ public class Template implements ProcessingConfiguration, CustomStateScope {
     *     
     * @return the {@link Environment} object created for processing. Call {@link Environment#process()} to process the
     *    template.
-    * 
-    * @throws TemplateException if an exception occurs while setting up the Environment object.
-    * @throws IOException if an exception occurs doing any auto-imports
+    *
+    * @throws TemplateException
+    *             if an exception occurs during template processing
+    * @throws ObjectWrappingException
+    *             if the {@code dataModel} couldn't be wrapped; note that this extends {@link TemplateException}
+    * @throws IOException
+    *             if an I/O exception occurs during writing to the writer.
     */
     public Environment createProcessingEnvironment(Object dataModel, Writer out, ObjectWrapper wrapper)
     throws TemplateException, IOException {

http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/d73da6da/freemarker-core/src/main/java/org/apache/freemarker/core/TemplateException.java
----------------------------------------------------------------------
diff --git a/freemarker-core/src/main/java/org/apache/freemarker/core/TemplateException.java b/freemarker-core/src/main/java/org/apache/freemarker/core/TemplateException.java
index bcbb645..7e7dd09 100644
--- a/freemarker-core/src/main/java/org/apache/freemarker/core/TemplateException.java
+++ b/freemarker-core/src/main/java/org/apache/freemarker/core/TemplateException.java
@@ -101,7 +101,11 @@ public class TemplateException extends Exception {
     public TemplateException(Throwable cause, Environment env) {
         this(null, cause, env);
     }
-    
+
+    public TemplateException(String description, Throwable cause) {
+        this(description, cause, null);
+    }
+
     /**
      * Constructs a TemplateException with both a description of the error
      * that occurred and the underlying Exception that caused this exception
@@ -136,7 +140,7 @@ public class TemplateException extends Exception {
     // Permutation group:
 
     public TemplateException(String description) {
-        this(description, null);
+        this(description, (Throwable) null);
     }
 
     TemplateException(Environment env, String description) {

http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/d73da6da/freemarker-core/src/main/java/org/apache/freemarker/core/_CoreAPI.java
----------------------------------------------------------------------
diff --git a/freemarker-core/src/main/java/org/apache/freemarker/core/_CoreAPI.java b/freemarker-core/src/main/java/org/apache/freemarker/core/_CoreAPI.java
index df7042b..9110a5d 100644
--- a/freemarker-core/src/main/java/org/apache/freemarker/core/_CoreAPI.java
+++ b/freemarker-core/src/main/java/org/apache/freemarker/core/_CoreAPI.java
@@ -20,7 +20,6 @@
 package org.apache.freemarker.core;
 
 import org.apache.freemarker.core.model.TemplateModel;
-import org.apache.freemarker.core.model.TemplateModelException;
 import org.apache.freemarker.core.util._NullArgumentException;
 
 /**
@@ -47,20 +46,6 @@ public final class _CoreAPI {
         }
     }
 
-    /**
-     * The work around the problematic cases where we should throw a {@link TemplateException}, but we are inside
-     * a {@link TemplateModel} method and so we can only throw {@link TemplateModelException}-s.  
-     */
-    // [FM3] Get rid of this problem, then delete this method
-    public static TemplateModelException ensureIsTemplateModelException(String modelOpMsg, TemplateException e) {
-        if (e instanceof TemplateModelException) {
-            return (TemplateModelException) e;
-        } else {
-            return new _TemplateModelException(
-                    e.getBlamedExpression(), e.getCause(), e.getEnvironment(), modelOpMsg);
-        }
-    }
-
     public static boolean isMacro(Class<? extends TemplateModel> cl) {
         return Environment.TemplateLanguageDirective.class.isAssignableFrom(cl);
     }


Mime
View raw message