freemarker-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ddek...@apache.org
Subject [4/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:38 GMT
http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/d73da6da/freemarker-core/src/main/java/org/apache/freemarker/core/_EvalUtils.java
----------------------------------------------------------------------
diff --git a/freemarker-core/src/main/java/org/apache/freemarker/core/_EvalUtils.java b/freemarker-core/src/main/java/org/apache/freemarker/core/_EvalUtils.java
index 17f6459..3e21a2b 100644
--- a/freemarker-core/src/main/java/org/apache/freemarker/core/_EvalUtils.java
+++ b/freemarker-core/src/main/java/org/apache/freemarker/core/_EvalUtils.java
@@ -30,12 +30,12 @@ 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;
 import org.apache.freemarker.core.outputformat.MarkupOutputFormat;
 import org.apache.freemarker.core.util.BugException;
+import org.apache.freemarker.core.util._ClassUtils;
 import org.apache.freemarker.core.valueformat.TemplateDateFormat;
 import org.apache.freemarker.core.valueformat.TemplateNumberFormat;
 import org.apache.freemarker.core.valueformat.TemplateValueFormat;
@@ -60,7 +60,7 @@ public class _EvalUtils {
      * @param expr {@code null} is allowed, but may results in less helpful error messages
      */
     public static String modelToString(TemplateScalarModel model, ASTExpression expr)
-    throws TemplateModelException {
+    throws TemplateException {
         String value = model.getAsString();
         if (value == null) {
             throw newModelHasStoredNullException(String.class, model, expr);
@@ -72,7 +72,7 @@ public class _EvalUtils {
      * @param expr {@code null} is allowed, but may results in less helpful error messages
      */
     public static Number modelToNumber(TemplateNumberModel model, ASTExpression expr)
-        throws TemplateModelException {
+        throws TemplateException {
         Number value = model.getAsNumber();
         if (value == null) throw newModelHasStoredNullException(Number.class, model, expr);
         return value;
@@ -82,17 +82,20 @@ public class _EvalUtils {
      * @param expr {@code null} is allowed, but may results in less helpful error messages
      */
     public static Date modelToDate(TemplateDateModel model, ASTExpression expr)
-        throws TemplateModelException {
+        throws TemplateException {
         Date value = model.getAsDate();
         if (value == null) throw newModelHasStoredNullException(Date.class, model, expr);
         return value;
     }
     
     /** Signals the buggy case where we have a non-null model, but it wraps a null. */
-    public static TemplateModelException newModelHasStoredNullException(
-            Class expected, TemplateModel model, ASTExpression expr) {
-        return new _TemplateModelException(expr,
-                _TemplateModelException.modelHasStoredNullDescription(expected, model));
+    public static TemplateException newModelHasStoredNullException(
+            Class<?> expected, TemplateModel model, ASTExpression expr) {
+        return new TemplateException(expr,
+                "The FreeMarker value exists, but has nothing inside it; the TemplateModel object (class: ",
+                model.getClass().getName(), ") has returned a null",
+                (expected != null ? new Object[] { " instead of a ", _ClassUtils.getShortClassName(expected) } : ""),
+                ". This is possibly a bug in the non-FreeMarker code that builds the data-model.");
     }
 
     /**
@@ -355,19 +358,19 @@ public class _EvalUtils {
             throws TemplateException {
         if (tm instanceof TemplateNumberModel) {
             TemplateNumberModel tnm = (TemplateNumberModel) tm; 
-            TemplateNumberFormat format = env.getTemplateNumberFormat(exp, false);
+            TemplateNumberFormat format = env.getTemplateNumberFormat(exp);
             try {
                 return assertFormatResultNotNull(format.format(tnm));
             } catch (TemplateValueFormatException e) {
-                throw MessageUtils.newCantFormatNumberException(format, exp, e, false);
+                throw MessageUtils.newCantFormatNumberException(format, exp, e);
             }
         } else if (tm instanceof TemplateDateModel) {
             TemplateDateModel tdm = (TemplateDateModel) tm;
-            TemplateDateFormat format = env.getTemplateDateFormat(tdm, exp, false);
+            TemplateDateFormat format = env.getTemplateDateFormat(tdm, exp);
             try {
                 return assertFormatResultNotNull(format.format(tdm));
             } catch (TemplateValueFormatException e) {
-                throw MessageUtils.newCantFormatDateException(format, exp, e, false);
+                throw MessageUtils.newCantFormatDateException(format, exp, e);
             }
         } else if (tm instanceof TemplateMarkupOutputModel) {
             return tm;
@@ -390,19 +393,19 @@ public class _EvalUtils {
             throws TemplateException {
         if (tm instanceof TemplateNumberModel) {
             TemplateNumberModel tnm = (TemplateNumberModel) tm; 
-            TemplateNumberFormat format = env.getTemplateNumberFormat(exp, false);
+            TemplateNumberFormat format = env.getTemplateNumberFormat(exp);
             try {
                 return ensureFormatResultString(format.format(tnm), exp, env);
             } catch (TemplateValueFormatException e) {
-                throw MessageUtils.newCantFormatNumberException(format, exp, e, false);
+                throw MessageUtils.newCantFormatNumberException(format, exp, e);
             }
         } else if (tm instanceof TemplateDateModel) {
             TemplateDateModel tdm = (TemplateDateModel) tm;
-            TemplateDateFormat format = env.getTemplateDateFormat(tdm, exp, false);
+            TemplateDateFormat format = env.getTemplateDateFormat(tdm, exp);
             try {
                 return ensureFormatResultString(format.format(tdm), exp, env);
             } catch (TemplateValueFormatException e) {
-                throw MessageUtils.newCantFormatDateException(format, exp, e, false);
+                throw MessageUtils.newCantFormatDateException(format, exp, e);
             }
         } else { 
             return coerceModelToTextualCommon(tm, exp, seqTip, false, false, env);
@@ -421,9 +424,9 @@ public class _EvalUtils {
     static String coerceModelToPlainText(TemplateModel tm, ASTExpression exp, String seqTip,
             Environment env) throws TemplateException {
         if (tm instanceof TemplateNumberModel) {
-            return assertFormatResultNotNull(env.formatNumberToPlainText((TemplateNumberModel) tm, exp, false));
+            return assertFormatResultNotNull(env.formatNumberToPlainText((TemplateNumberModel) tm, exp));
         } else if (tm instanceof TemplateDateModel) {
-            return assertFormatResultNotNull(env.formatDateToPlainText((TemplateDateModel) tm, exp, false));
+            return assertFormatResultNotNull(env.formatDateToPlainText((TemplateDateModel) tm, exp));
         } else {
             return coerceModelToTextualCommon(tm, exp, seqTip, false, false, env);
         }

http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/d73da6da/freemarker-core/src/main/java/org/apache/freemarker/core/_ObjectBuilderSettingEvaluator.java
----------------------------------------------------------------------
diff --git a/freemarker-core/src/main/java/org/apache/freemarker/core/_ObjectBuilderSettingEvaluator.java b/freemarker-core/src/main/java/org/apache/freemarker/core/_ObjectBuilderSettingEvaluator.java
index 7fcf25d..0039249 100644
--- a/freemarker-core/src/main/java/org/apache/freemarker/core/_ObjectBuilderSettingEvaluator.java
+++ b/freemarker-core/src/main/java/org/apache/freemarker/core/_ObjectBuilderSettingEvaluator.java
@@ -35,9 +35,9 @@ import java.util.Locale;
 import java.util.Map;
 import java.util.Properties;
 
+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.TemplateModelException;
 import org.apache.freemarker.core.model.impl.DefaultObjectWrapper;
 import org.apache.freemarker.core.model.impl.JavaMethodModel;
 import org.apache.freemarker.core.model.impl.RestrictedObjectWrapper;
@@ -58,8 +58,8 @@ import org.apache.freemarker.core.templateresolver.OrMatcher;
 import org.apache.freemarker.core.templateresolver.PathGlobMatcher;
 import org.apache.freemarker.core.templateresolver.PathRegexMatcher;
 import org.apache.freemarker.core.util.BugException;
-import org.apache.freemarker.core.util.TemplateLanguageUtils;
 import org.apache.freemarker.core.util.GenericParseException;
+import org.apache.freemarker.core.util.TemplateLanguageUtils;
 import org.apache.freemarker.core.util._ClassUtils;
 import org.apache.freemarker.core.util._StringUtils;
 
@@ -997,7 +997,7 @@ public class _ObjectBuilderSettingEvaluator {
                 for (int i = 0; i < positionalParamValues.size(); i++) {
                     try {
                         tmArgs[i] = ow.wrap(positionalParamValues.get(i));
-                    } catch (TemplateModelException e) {
+                    } catch (ObjectWrappingException e) {
                         throw new _ObjectBuilderSettingEvaluationException("Failed to wrap arg #" + (i + 1), e);
                     }
                 }

http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/d73da6da/freemarker-core/src/main/java/org/apache/freemarker/core/_TemplateModelException.java
----------------------------------------------------------------------
diff --git a/freemarker-core/src/main/java/org/apache/freemarker/core/_TemplateModelException.java b/freemarker-core/src/main/java/org/apache/freemarker/core/_TemplateModelException.java
deleted file mode 100644
index 10ad99f..0000000
--- a/freemarker-core/src/main/java/org/apache/freemarker/core/_TemplateModelException.java
+++ /dev/null
@@ -1,133 +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.model.TemplateModel;
-import org.apache.freemarker.core.model.TemplateModelException;
-import org.apache.freemarker.core.util._ClassUtils;
-
-public class _TemplateModelException extends TemplateModelException {
-
-    // Note: On Java 5 we will use `String descPart1, Object... furtherDescParts` instead of `Object[] descriptionParts`
-    //       and `String description`. That's why these are at the end of the parameter list.
-    
-    // -----------------------------------------------------------------------------------------------------------------
-    // Permutation group:
-    
-    public _TemplateModelException(String description) {
-        super(description);
-    }
-
-    // -----------------------------------------------------------------------------------------------------------------
-    // Permutation group:
-
-    public _TemplateModelException(Throwable cause, String description) {
-        this(cause, null, description);
-    }
-
-    public _TemplateModelException(Environment env, String description) {
-        this((Throwable) null, env, description);
-    }
-    
-    public _TemplateModelException(Throwable cause, Environment env) {
-        this(cause, env, (String) null);
-    }
-
-    public _TemplateModelException(Throwable cause) {
-        this(cause, null, (String) null);
-    }
-    
-    public _TemplateModelException(Throwable cause, Environment env, String description) {
-        super(cause, env, description, true);
-    }
-
-    // -----------------------------------------------------------------------------------------------------------------
-    // Permutation group:
-    
-    public _TemplateModelException(_ErrorDescriptionBuilder description) {
-        this(null, description);
-    }
-
-    public _TemplateModelException(Environment env, _ErrorDescriptionBuilder description) {
-        this(null, env, description);
-    }
-
-    public _TemplateModelException(Throwable cause, Environment env, _ErrorDescriptionBuilder description) {
-        super(cause, env, description, true);
-    }
-
-    // -----------------------------------------------------------------------------------------------------------------
-    // Permutation group:
-    
-    public _TemplateModelException(Object... descriptionParts) {
-        this((Environment) null, descriptionParts);
-    }
-
-    public _TemplateModelException(Environment env, Object... descriptionParts) {
-        this((Throwable) null, env, descriptionParts);
-    }
-
-    public _TemplateModelException(Throwable cause, Object... descriptionParts) {
-        this(cause, null, descriptionParts);
-    }
-
-    public _TemplateModelException(Throwable cause, Environment env, Object... descriptionParts) {
-        super(cause, env, new _ErrorDescriptionBuilder(descriptionParts), true);
-    }
-
-    // -----------------------------------------------------------------------------------------------------------------
-    // Permutation group:
-    
-    public _TemplateModelException(ASTExpression blamed, Object... descriptionParts) {
-        this(blamed, null, descriptionParts);
-    }
-
-    public _TemplateModelException(ASTExpression blamed, Environment env, Object... descriptionParts) {
-        this(blamed, null, env, descriptionParts);
-    }
-
-    public _TemplateModelException(ASTExpression blamed, Throwable cause, Environment env, Object... descriptionParts) {
-        super(cause, env, new _ErrorDescriptionBuilder(descriptionParts).blame(blamed), true);
-    }
-
-    // -----------------------------------------------------------------------------------------------------------------
-    // Permutation group:
-    
-    public _TemplateModelException(ASTExpression blamed, String description) {
-        this(blamed, null, description);
-    }
-
-    public _TemplateModelException(ASTExpression blamed, Environment env, String description) {
-        this(blamed, null, env, description);
-    }
-
-    public _TemplateModelException(ASTExpression blamed, Throwable cause, Environment env, String description) {
-        super(cause, env, new _ErrorDescriptionBuilder(description).blame(blamed), true);
-    }
-
-    static Object[] modelHasStoredNullDescription(Class expected, TemplateModel model) {
-        return new Object[] {
-                "The FreeMarker value exists, but has nothing inside it; the TemplateModel object (class: ",
-                model.getClass().getName(), ") has returned a null",
-                (expected != null ? new Object[] { " instead of a ", _ClassUtils.getShortClassName(expected) } : ""),
-                ". This is possibly a bug in the non-FreeMarker code that builds the data-model." };
-    }
-    
-}

http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/d73da6da/freemarker-core/src/main/java/org/apache/freemarker/core/debug/DebugModel.java
----------------------------------------------------------------------
diff --git a/freemarker-core/src/main/java/org/apache/freemarker/core/debug/DebugModel.java b/freemarker-core/src/main/java/org/apache/freemarker/core/debug/DebugModel.java
index 5f4c473..41d1742 100644
--- a/freemarker-core/src/main/java/org/apache/freemarker/core/debug/DebugModel.java
+++ b/freemarker-core/src/main/java/org/apache/freemarker/core/debug/DebugModel.java
@@ -23,7 +23,7 @@ import java.rmi.Remote;
 import java.rmi.RemoteException;
 import java.util.Date;
 
-import org.apache.freemarker.core.model.TemplateModelException;
+import org.apache.freemarker.core.TemplateException;
 
 /**
  * Represents the debugger-side mirror of a TemplateModel object, a Template
@@ -52,51 +52,51 @@ public interface DebugModel extends Remote {
     public static final int TYPE_CONFIGURATION = 8192;
     
     public String getAsString()
-    throws TemplateModelException,
+    throws TemplateException,
         RemoteException;
         
     public Number getAsNumber()
-    throws TemplateModelException,
+    throws TemplateException,
         RemoteException;
     
     public boolean getAsBoolean()
-    throws TemplateModelException,
+    throws TemplateException,
         RemoteException;
     
     public Date getAsDate()
-    throws TemplateModelException,
+    throws TemplateException,
         RemoteException;
     
     public int getDateType()
-    throws TemplateModelException,
+    throws TemplateException,
         RemoteException;
         
     public int size()
-    throws TemplateModelException,
+    throws TemplateException,
         RemoteException;
         
     public DebugModel get(int index)
-    throws TemplateModelException,
+    throws TemplateException,
         RemoteException;
     
     public DebugModel[] get(int fromIndex, int toIndex)
-    throws TemplateModelException,
+    throws TemplateException,
         RemoteException;
         
     public DebugModel get(String key)
-    throws TemplateModelException,
+    throws TemplateException,
         RemoteException;
         
     public DebugModel[] get(String[] keys)
-    throws TemplateModelException,
+    throws TemplateException,
         RemoteException;
     
     public DebugModel[] getCollection()
-    throws TemplateModelException,
+    throws TemplateException,
         RemoteException;
 
     public String[] keys()
-    throws TemplateModelException,
+    throws TemplateException,
         RemoteException;
     
     public int getModelTypes()

http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/d73da6da/freemarker-core/src/main/java/org/apache/freemarker/core/debug/RmiDebugModelImpl.java
----------------------------------------------------------------------
diff --git a/freemarker-core/src/main/java/org/apache/freemarker/core/debug/RmiDebugModelImpl.java b/freemarker-core/src/main/java/org/apache/freemarker/core/debug/RmiDebugModelImpl.java
index 20e9f50..01becc2 100644
--- a/freemarker-core/src/main/java/org/apache/freemarker/core/debug/RmiDebugModelImpl.java
+++ b/freemarker-core/src/main/java/org/apache/freemarker/core/debug/RmiDebugModelImpl.java
@@ -25,6 +25,7 @@ import java.util.ArrayList;
 import java.util.Date;
 import java.util.List;
 
+import org.apache.freemarker.core.TemplateException;
 import org.apache.freemarker.core.model.TemplateBooleanModel;
 import org.apache.freemarker.core.model.TemplateCollectionModel;
 import org.apache.freemarker.core.model.TemplateDateModel;
@@ -33,7 +34,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.TemplateNumberModel;
 import org.apache.freemarker.core.model.TemplateScalarModel;
@@ -57,17 +57,17 @@ class RmiDebugModelImpl extends UnicastRemoteObject implements DebugModel {
         return (DebugModel) RmiDebuggedEnvironmentImpl.getCachedWrapperFor(tm);
     }
     @Override
-    public String getAsString() throws TemplateModelException {
+    public String getAsString() throws TemplateException {
         return ((TemplateScalarModel) model).getAsString();
     }
 
     @Override
-    public Number getAsNumber() throws TemplateModelException {
+    public Number getAsNumber() throws TemplateException {
         return ((TemplateNumberModel) model).getAsNumber();
     }
 
     @Override
-    public Date getAsDate() throws TemplateModelException {
+    public Date getAsDate() throws TemplateException {
         return ((TemplateDateModel) model).getAsDate();
     }
 
@@ -77,12 +77,12 @@ class RmiDebugModelImpl extends UnicastRemoteObject implements DebugModel {
     }
 
     @Override
-    public boolean getAsBoolean() throws TemplateModelException {
+    public boolean getAsBoolean() throws TemplateException {
         return ((TemplateBooleanModel) model).getAsBoolean();
     }
 
     @Override
-    public int size() throws TemplateModelException {
+    public int size() throws TemplateException {
         if (model instanceof TemplateSequenceModel) {
             return ((TemplateSequenceModel) model).size();
         }
@@ -90,12 +90,12 @@ class RmiDebugModelImpl extends UnicastRemoteObject implements DebugModel {
     }
 
     @Override
-    public DebugModel get(int index) throws TemplateModelException, RemoteException {
+    public DebugModel get(int index) throws TemplateException, RemoteException {
         return getDebugModel(((TemplateSequenceModel) model).get(index));
     }
     
     @Override
-    public DebugModel[] get(int fromIndex, int toIndex) throws TemplateModelException, RemoteException {
+    public DebugModel[] get(int fromIndex, int toIndex) throws TemplateException, RemoteException {
         DebugModel[] dm = new DebugModel[toIndex - fromIndex];
         TemplateSequenceModel s = (TemplateSequenceModel) model;
         for (int i = fromIndex; i < toIndex; i++) {
@@ -105,7 +105,7 @@ class RmiDebugModelImpl extends UnicastRemoteObject implements DebugModel {
     }
 
     @Override
-    public DebugModel[] getCollection() throws TemplateModelException, RemoteException {
+    public DebugModel[] getCollection() throws TemplateException, RemoteException {
         List list = new ArrayList();
         TemplateModelIterator i = ((TemplateCollectionModel) model).iterator();
         while (i.hasNext()) {
@@ -115,12 +115,12 @@ class RmiDebugModelImpl extends UnicastRemoteObject implements DebugModel {
     }
     
     @Override
-    public DebugModel get(String key) throws TemplateModelException, RemoteException {
+    public DebugModel get(String key) throws TemplateException, RemoteException {
         return getDebugModel(((TemplateHashModel) model).get(key));
     }
     
     @Override
-    public DebugModel[] get(String[] keys) throws TemplateModelException, RemoteException {
+    public DebugModel[] get(String[] keys) throws TemplateException, RemoteException {
         DebugModel[] dm = new DebugModel[keys.length];
         TemplateHashModel h = (TemplateHashModel) model;
         for (int i = 0; i < keys.length; i++) {
@@ -130,7 +130,7 @@ class RmiDebugModelImpl extends UnicastRemoteObject implements DebugModel {
     }
 
     @Override
-    public String[] keys() throws TemplateModelException {
+    public String[] keys() throws TemplateException {
         TemplateHashModelEx h = (TemplateHashModelEx) model;
         List list = new ArrayList();
         TemplateModelIterator i = h.keys().iterator();

http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/d73da6da/freemarker-core/src/main/java/org/apache/freemarker/core/debug/RmiDebuggedEnvironmentImpl.java
----------------------------------------------------------------------
diff --git a/freemarker-core/src/main/java/org/apache/freemarker/core/debug/RmiDebuggedEnvironmentImpl.java b/freemarker-core/src/main/java/org/apache/freemarker/core/debug/RmiDebuggedEnvironmentImpl.java
index f23186c..af0958a 100644
--- a/freemarker-core/src/main/java/org/apache/freemarker/core/debug/RmiDebuggedEnvironmentImpl.java
+++ b/freemarker-core/src/main/java/org/apache/freemarker/core/debug/RmiDebuggedEnvironmentImpl.java
@@ -37,10 +37,10 @@ import org.apache.freemarker.core.Environment;
 import org.apache.freemarker.core.MutableProcessingConfiguration;
 import org.apache.freemarker.core.ProcessingConfiguration;
 import org.apache.freemarker.core.Template;
+import org.apache.freemarker.core.TemplateException;
 import org.apache.freemarker.core.model.TemplateCollectionModel;
 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.impl.DefaultObjectWrapper;
 import org.apache.freemarker.core.model.impl.SimpleCollection;
 import org.apache.freemarker.core.model.impl.SimpleScalar;
@@ -138,7 +138,7 @@ class RmiDebuggedEnvironmentImpl extends RmiDebugModelImpl implements DebuggedEn
         }
 
         @Override
-        public TemplateCollectionModel values() throws TemplateModelException {
+        public TemplateCollectionModel values() throws TemplateException {
             Collection keys = keySet();
             List list = new ArrayList(keys.size());
             
@@ -184,7 +184,7 @@ class RmiDebuggedEnvironmentImpl extends RmiDebugModelImpl implements DebuggedEn
         }
         
         @Override
-        public TemplateModel get(String key) throws TemplateModelException {
+        public TemplateModel get(String key) throws TemplateException {
             return null; // TODO
         }
 
@@ -216,7 +216,7 @@ class RmiDebuggedEnvironmentImpl extends RmiDebugModelImpl implements DebuggedEn
         }
 
         @Override
-        public TemplateModel get(String key) throws TemplateModelException {
+        public TemplateModel get(String key) throws TemplateException {
             if ("sharedVariables".equals(key)) {
                 return sharedVariables; 
             } else {
@@ -242,12 +242,12 @@ class RmiDebuggedEnvironmentImpl extends RmiDebugModelImpl implements DebuggedEn
         }
 
         @Override
-        public TemplateModel get(String key) throws TemplateModelException {
+        public TemplateModel get(String key) throws TemplateException {
             if ("configuration".equals(key)) {
                 try {
                     return (TemplateModel) getCachedWrapperFor(((Template) ProcessingConfiguration).getConfiguration());
                 } catch (RemoteException e) {
-                    throw new TemplateModelException(e);
+                    throw new TemplateException(e);
                 }
             }
             if ("name".equals(key)) {
@@ -273,13 +273,13 @@ class RmiDebuggedEnvironmentImpl extends RmiDebugModelImpl implements DebuggedEn
             Collection keySet() {
                 try {
                     return ((Environment) ProcessingConfiguration).getKnownVariableNames();
-                } catch (TemplateModelException e) {
+                } catch (TemplateException e) {
                     throw new UndeclaredThrowableException(e);
                 }
             }
         
             @Override
-            public TemplateModel get(String key) throws TemplateModelException {
+            public TemplateModel get(String key) throws TemplateException {
                 return ((Environment) ProcessingConfiguration).getVariable(key);
             }
         };
@@ -294,7 +294,7 @@ class RmiDebuggedEnvironmentImpl extends RmiDebugModelImpl implements DebuggedEn
         }
 
         @Override
-        public TemplateModel get(String key) throws TemplateModelException {
+        public TemplateModel get(String key) throws TemplateException {
             if ("currentNamespace".equals(key)) {
                 return ((Environment) ProcessingConfiguration).getCurrentNamespace();
             }
@@ -314,14 +314,14 @@ class RmiDebuggedEnvironmentImpl extends RmiDebugModelImpl implements DebuggedEn
                 try {
                     return (TemplateModel) getCachedWrapperFor(((Environment) ProcessingConfiguration).getMainTemplate());
                 } catch (RemoteException e) {
-                    throw new TemplateModelException(e);
+                    throw new TemplateException(e);
                 }
             }
             if ("currentTemplate".equals(key)) {
                 try {
                     return (TemplateModel) getCachedWrapperFor(((Environment) ProcessingConfiguration).getCurrentTemplate());
                 } catch (RemoteException e) {
-                    throw new TemplateModelException(e);
+                    throw new TemplateException(e);
                 }
             }
             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/model/EmptyCollectionExModel.java
----------------------------------------------------------------------
diff --git a/freemarker-core/src/main/java/org/apache/freemarker/core/model/EmptyCollectionExModel.java b/freemarker-core/src/main/java/org/apache/freemarker/core/model/EmptyCollectionExModel.java
index 06f3366..34f8029 100644
--- a/freemarker-core/src/main/java/org/apache/freemarker/core/model/EmptyCollectionExModel.java
+++ b/freemarker-core/src/main/java/org/apache/freemarker/core/model/EmptyCollectionExModel.java
@@ -21,20 +21,22 @@ package org.apache.freemarker.core.model;
 
 import java.io.Serializable;
 
+import org.apache.freemarker.core.TemplateException;
+
 class EmptyCollectionExModel implements TemplateCollectionModelEx, Serializable {
 
     @Override
-    public int size() throws TemplateModelException {
+    public int size() throws TemplateException {
         return 0;
     }
 
     @Override
-    public boolean isEmpty() throws TemplateModelException {
+    public boolean isEmpty() throws TemplateException {
         return true;
     }
 
     @Override
-    public TemplateModelIterator iterator() throws TemplateModelException {
+    public TemplateModelIterator iterator() throws TemplateException {
         return TemplateModelIterator.EMPTY_ITERATOR;
     }
 

http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/d73da6da/freemarker-core/src/main/java/org/apache/freemarker/core/model/EmptyHashModel.java
----------------------------------------------------------------------
diff --git a/freemarker-core/src/main/java/org/apache/freemarker/core/model/EmptyHashModel.java b/freemarker-core/src/main/java/org/apache/freemarker/core/model/EmptyHashModel.java
index a8aa2b7..0b32160 100644
--- a/freemarker-core/src/main/java/org/apache/freemarker/core/model/EmptyHashModel.java
+++ b/freemarker-core/src/main/java/org/apache/freemarker/core/model/EmptyHashModel.java
@@ -21,35 +21,37 @@ package org.apache.freemarker.core.model;
 
 import java.io.Serializable;
 
+import org.apache.freemarker.core.TemplateException;
+
 class EmptyHashModel implements TemplateHashModelEx2, Serializable {
 
     @Override
-    public int size() throws TemplateModelException {
+    public int size() throws TemplateException {
         return 0;
     }
 
     @Override
-    public TemplateCollectionModel keys() throws TemplateModelException {
+    public TemplateCollectionModel keys() throws TemplateException {
         return TemplateCollectionModel.EMPTY_COLLECTION;
     }
 
     @Override
-    public TemplateCollectionModel values() throws TemplateModelException {
+    public TemplateCollectionModel values() throws TemplateException {
         return TemplateCollectionModel.EMPTY_COLLECTION;
     }
 
     @Override
-    public TemplateModel get(String key) throws TemplateModelException {
+    public TemplateModel get(String key) throws TemplateException {
         return null;
     }
 
     @Override
-    public boolean isEmpty() throws TemplateModelException {
+    public boolean isEmpty() throws TemplateException {
         return true;
     }
 
     @Override
-    public KeyValuePairIterator keyValuePairIterator() throws TemplateModelException {
+    public KeyValuePairIterator keyValuePairIterator() throws TemplateException {
         return EmptyKeyValuePairIterator.EMPTY_KEY_VALUE_PAIR_ITERATOR;
     }
 }

http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/d73da6da/freemarker-core/src/main/java/org/apache/freemarker/core/model/EmptyIteratorModel.java
----------------------------------------------------------------------
diff --git a/freemarker-core/src/main/java/org/apache/freemarker/core/model/EmptyIteratorModel.java b/freemarker-core/src/main/java/org/apache/freemarker/core/model/EmptyIteratorModel.java
index be0f0ea..a0b47e7 100644
--- a/freemarker-core/src/main/java/org/apache/freemarker/core/model/EmptyIteratorModel.java
+++ b/freemarker-core/src/main/java/org/apache/freemarker/core/model/EmptyIteratorModel.java
@@ -21,15 +21,17 @@ package org.apache.freemarker.core.model;
 
 import java.io.Serializable;
 
+import org.apache.freemarker.core.TemplateException;
+
 class EmptyIteratorModel implements TemplateModelIterator, Serializable {
 
     @Override
-    public TemplateModel next() throws TemplateModelException {
-        throw new TemplateModelException("The collection has no more elements.");
+    public TemplateModel next() throws TemplateException {
+        throw new TemplateException("The collection has no more elements.");
     }
 
     @Override
-    public boolean hasNext() throws TemplateModelException {
+    public boolean hasNext() {
         return false;
     }
 

http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/d73da6da/freemarker-core/src/main/java/org/apache/freemarker/core/model/EmptyKeyValuePairIterator.java
----------------------------------------------------------------------
diff --git a/freemarker-core/src/main/java/org/apache/freemarker/core/model/EmptyKeyValuePairIterator.java b/freemarker-core/src/main/java/org/apache/freemarker/core/model/EmptyKeyValuePairIterator.java
index 37073a3..83a0650 100644
--- a/freemarker-core/src/main/java/org/apache/freemarker/core/model/EmptyKeyValuePairIterator.java
+++ b/freemarker-core/src/main/java/org/apache/freemarker/core/model/EmptyKeyValuePairIterator.java
@@ -21,15 +21,17 @@ package org.apache.freemarker.core.model;
 
 import java.util.NoSuchElementException;
 
+import org.apache.freemarker.core.TemplateException;
+
 class EmptyKeyValuePairIterator implements TemplateHashModelEx2.KeyValuePairIterator {
 
     @Override
-    public boolean hasNext() throws TemplateModelException {
+    public boolean hasNext() throws TemplateException {
         return false;
     }
 
     @Override
-    public TemplateHashModelEx2.KeyValuePair next() throws TemplateModelException {
+    public TemplateHashModelEx2.KeyValuePair next() throws TemplateException {
         throw new NoSuchElementException("Can't retrieve element from empty key-value pair iterator.");
     }
 

http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/d73da6da/freemarker-core/src/main/java/org/apache/freemarker/core/model/EmptySequenceModel.java
----------------------------------------------------------------------
diff --git a/freemarker-core/src/main/java/org/apache/freemarker/core/model/EmptySequenceModel.java b/freemarker-core/src/main/java/org/apache/freemarker/core/model/EmptySequenceModel.java
index 5f352af..b6a176e 100644
--- a/freemarker-core/src/main/java/org/apache/freemarker/core/model/EmptySequenceModel.java
+++ b/freemarker-core/src/main/java/org/apache/freemarker/core/model/EmptySequenceModel.java
@@ -21,15 +21,17 @@ package org.apache.freemarker.core.model;
 
 import java.io.Serializable;
 
+import org.apache.freemarker.core.TemplateException;
+
 class EmptySequenceModel implements TemplateSequenceModel, Serializable {
 
     @Override
-    public TemplateModel get(int index) throws TemplateModelException {
+    public TemplateModel get(int index) throws TemplateException {
         return null;
     }
 
     @Override
-    public int size() throws TemplateModelException {
+    public int size() throws TemplateException {
         return 0;
     }
 

http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/d73da6da/freemarker-core/src/main/java/org/apache/freemarker/core/model/GeneralPurposeNothing.java
----------------------------------------------------------------------
diff --git a/freemarker-core/src/main/java/org/apache/freemarker/core/model/GeneralPurposeNothing.java b/freemarker-core/src/main/java/org/apache/freemarker/core/model/GeneralPurposeNothing.java
index ecd4ebb..6a25f09 100644
--- a/freemarker-core/src/main/java/org/apache/freemarker/core/model/GeneralPurposeNothing.java
+++ b/freemarker-core/src/main/java/org/apache/freemarker/core/model/GeneralPurposeNothing.java
@@ -63,8 +63,8 @@ implements TemplateBooleanModel, TemplateScalarModel, TemplateSequenceModel, Tem
     }
 
     @Override
-    public TemplateModel get(int i) throws TemplateModelException {
-        throw new TemplateModelException("Empty list");
+    public TemplateModel get(int i) throws TemplateException {
+        throw new TemplateException("Can't get item from an empty sequence.");
     }
 
     @Override
@@ -93,7 +93,7 @@ implements TemplateBooleanModel, TemplateScalarModel, TemplateSequenceModel, Tem
     }
 
     @Override
-    public KeyValuePairIterator keyValuePairIterator() throws TemplateModelException {
+    public KeyValuePairIterator keyValuePairIterator() throws TemplateException {
         return EmptyKeyValuePairIterator.EMPTY_KEY_VALUE_PAIR_ITERATOR;
     }
 

http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/d73da6da/freemarker-core/src/main/java/org/apache/freemarker/core/model/ObjectWrapper.java
----------------------------------------------------------------------
diff --git a/freemarker-core/src/main/java/org/apache/freemarker/core/model/ObjectWrapper.java b/freemarker-core/src/main/java/org/apache/freemarker/core/model/ObjectWrapper.java
index 42f09d8..ff251aa 100644
--- a/freemarker-core/src/main/java/org/apache/freemarker/core/model/ObjectWrapper.java
+++ b/freemarker-core/src/main/java/org/apache/freemarker/core/model/ObjectWrapper.java
@@ -54,6 +54,6 @@ public interface ObjectWrapper {
      *     restricts how it can be used, like, then it can't be used to wrap
      *     {@linkplain Configuration#getSharedVariables() shared variables}).
      */
-    TemplateModel wrap(Object obj) throws TemplateModelException;
+    TemplateModel wrap(Object obj) throws ObjectWrappingException;
     
 }

http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/d73da6da/freemarker-core/src/main/java/org/apache/freemarker/core/model/ObjectWrapperAndUnwrapper.java
----------------------------------------------------------------------
diff --git a/freemarker-core/src/main/java/org/apache/freemarker/core/model/ObjectWrapperAndUnwrapper.java b/freemarker-core/src/main/java/org/apache/freemarker/core/model/ObjectWrapperAndUnwrapper.java
index 1161cca..fe13d02 100644
--- a/freemarker-core/src/main/java/org/apache/freemarker/core/model/ObjectWrapperAndUnwrapper.java
+++ b/freemarker-core/src/main/java/org/apache/freemarker/core/model/ObjectWrapperAndUnwrapper.java
@@ -19,6 +19,8 @@
 
 package org.apache.freemarker.core.model;
 
+import org.apache.freemarker.core.TemplateException;
+
 /**
  * <b>Experimental - subject to change:</b> Adds functionality to {@link ObjectWrapper} that creates a plain Java object
  * from a {@link TemplateModel}. This is usually implemented by {@link ObjectWrapper}-s and reverses
@@ -49,12 +51,12 @@ public interface ObjectWrapperAndUnwrapper extends ObjectWrapper {
      *         the template model. {@code null} must not be used to indicate an unwrapping failure. It must NOT be
      *         {@link #CANT_UNWRAP_TO_TARGET_CLASS}.
      * 
-     * @throws TemplateModelException
+     * @throws TemplateException
      *             If the unwrapping fails from any reason.
      * 
      * @see #tryUnwrapTo(TemplateModel, Class)
      */
-    Object unwrap(TemplateModel tm) throws TemplateModelException;
+    Object unwrap(TemplateModel tm) throws TemplateException;
 
     /**
      * Attempts to unwrap a {@link TemplateModel} to a plain Java object that's the instance of the given class (or is
@@ -71,12 +73,12 @@ public interface ObjectWrapperAndUnwrapper extends ObjectWrapper {
      *         result can be {@code null}). However, {@link #CANT_UNWRAP_TO_TARGET_CLASS} must not be returned if the
      *         {@code targetClass} parameter was {@code Object.class}.
      * 
-     * @throws TemplateModelException
+     * @throws TemplateException
      *             If the unwrapping fails for a reason than doesn't fit the meaning of the
      *             {@link #CANT_UNWRAP_TO_TARGET_CLASS} return value.
      * 
      * @see #unwrap(TemplateModel)
      */
-    Object tryUnwrapTo(TemplateModel tm, Class<?> targetClass) throws TemplateModelException;
+    Object tryUnwrapTo(TemplateModel tm, Class<?> targetClass) throws TemplateException;
 
 }

http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/d73da6da/freemarker-core/src/main/java/org/apache/freemarker/core/model/ObjectWrapperWithAPISupport.java
----------------------------------------------------------------------
diff --git a/freemarker-core/src/main/java/org/apache/freemarker/core/model/ObjectWrapperWithAPISupport.java b/freemarker-core/src/main/java/org/apache/freemarker/core/model/ObjectWrapperWithAPISupport.java
index 22b1f63..2140204 100644
--- a/freemarker-core/src/main/java/org/apache/freemarker/core/model/ObjectWrapperWithAPISupport.java
+++ b/freemarker-core/src/main/java/org/apache/freemarker/core/model/ObjectWrapperWithAPISupport.java
@@ -37,6 +37,6 @@ public interface ObjectWrapperWithAPISupport extends ObjectWrapper {
      * 
      * @return The {@link TemplateModel} through which the API of the object can be accessed. Can't be {@code null}.
      */
-    TemplateHashModel wrapAsAPI(Object obj) throws TemplateModelException;
+    TemplateHashModel wrapAsAPI(Object obj) throws ObjectWrappingException;
 
 }

http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/d73da6da/freemarker-core/src/main/java/org/apache/freemarker/core/model/ObjectWrappingException.java
----------------------------------------------------------------------
diff --git a/freemarker-core/src/main/java/org/apache/freemarker/core/model/ObjectWrappingException.java b/freemarker-core/src/main/java/org/apache/freemarker/core/model/ObjectWrappingException.java
new file mode 100644
index 0000000..3ed9c7e
--- /dev/null
+++ b/freemarker-core/src/main/java/org/apache/freemarker/core/model/ObjectWrappingException.java
@@ -0,0 +1,37 @@
+/*
+ * 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.model;
+
+import org.apache.freemarker.core.TemplateException;
+
+/**
+ * Thrown by {@link ObjectWrapper#wrap(Object)}.
+ */
+public class ObjectWrappingException extends TemplateException {
+
+    public ObjectWrappingException(String description, Throwable cause) {
+        super(description, cause);
+    }
+
+    public ObjectWrappingException(String description) {
+        super(description);
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/d73da6da/freemarker-core/src/main/java/org/apache/freemarker/core/model/TemplateBooleanModel.java
----------------------------------------------------------------------
diff --git a/freemarker-core/src/main/java/org/apache/freemarker/core/model/TemplateBooleanModel.java b/freemarker-core/src/main/java/org/apache/freemarker/core/model/TemplateBooleanModel.java
index 555e619..cf37ef2 100644
--- a/freemarker-core/src/main/java/org/apache/freemarker/core/model/TemplateBooleanModel.java
+++ b/freemarker-core/src/main/java/org/apache/freemarker/core/model/TemplateBooleanModel.java
@@ -21,6 +21,8 @@ package org.apache.freemarker.core.model;
 
 import java.io.Serializable;
 
+import org.apache.freemarker.core.TemplateException;
+
 /**
  * "boolean" template language data type; same as in Java; either {@code true} or {@code false}.
  * 
@@ -33,7 +35,7 @@ public interface TemplateBooleanModel extends TemplateModel, Serializable {
     /**
      * @return whether to interpret this object as true or false in a boolean context
      */
-    boolean getAsBoolean() throws TemplateModelException;
+    boolean getAsBoolean() throws TemplateException;
     
     /**
      * A singleton object to represent boolean false

http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/d73da6da/freemarker-core/src/main/java/org/apache/freemarker/core/model/TemplateCollectionModel.java
----------------------------------------------------------------------
diff --git a/freemarker-core/src/main/java/org/apache/freemarker/core/model/TemplateCollectionModel.java b/freemarker-core/src/main/java/org/apache/freemarker/core/model/TemplateCollectionModel.java
index 705f82a..d1db16c 100644
--- a/freemarker-core/src/main/java/org/apache/freemarker/core/model/TemplateCollectionModel.java
+++ b/freemarker-core/src/main/java/org/apache/freemarker/core/model/TemplateCollectionModel.java
@@ -21,6 +21,8 @@ package org.apache.freemarker.core.model;
 
 import java.util.Collection;
 
+import org.apache.freemarker.core.TemplateException;
+
 /**
  * "collection" template language data type: a collection of values that can be enumerated, but can't be or not meant to
  * be accessed by index or key. As such, this is not a super-interface of {@link TemplateSequenceModel}, and
@@ -30,7 +32,7 @@ import java.util.Collection;
  * 
  * <p>
  * The enumeration should be repeatable if that's possible with reasonable effort, otherwise a second enumeration
- * attempt is allowed to throw an {@link TemplateModelException}. Generally, the interface user Java code need not
+ * attempt is allowed to throw an {@link TemplateException}. Generally, the interface user Java code need not
  * handle that kind of exception, as in practice only the template author can handle it, by not listing such collections
  * twice.
  * 
@@ -45,6 +47,6 @@ public interface TemplateCollectionModel extends TemplateModel {
     /**
      * Retrieves a template model iterator that is used to iterate over the elements in this collection.
      */
-    TemplateModelIterator iterator() throws TemplateModelException;
+    TemplateModelIterator iterator() throws TemplateException;
 
 }

http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/d73da6da/freemarker-core/src/main/java/org/apache/freemarker/core/model/TemplateCollectionModelEx.java
----------------------------------------------------------------------
diff --git a/freemarker-core/src/main/java/org/apache/freemarker/core/model/TemplateCollectionModelEx.java b/freemarker-core/src/main/java/org/apache/freemarker/core/model/TemplateCollectionModelEx.java
index 2da95c1..730a267 100644
--- a/freemarker-core/src/main/java/org/apache/freemarker/core/model/TemplateCollectionModelEx.java
+++ b/freemarker-core/src/main/java/org/apache/freemarker/core/model/TemplateCollectionModelEx.java
@@ -21,6 +21,8 @@ package org.apache.freemarker.core.model;
 
 import java.util.Collection;
 
+import org.apache.freemarker.core.TemplateException;
+
 /**
  * "extended collection" template language data type: Adds size/emptiness querybility and "contains" test to
  * {@link TemplateCollectionModel}. The added extra operations is provided by all Java {@link Collection}-s, and
@@ -32,12 +34,12 @@ public interface TemplateCollectionModelEx extends TemplateCollectionModel {
      * Returns the number items in this collection, or {@link Integer#MAX_VALUE}, if there are more than
      * {@link Integer#MAX_VALUE} items.
      */
-    int size() throws TemplateModelException;
+    int size() throws TemplateException;
 
     /**
      * Returns if the collection contains any elements. This differs from {@code size() != 0} only in that the exact
      * number of items need not be calculated.
      */
-    boolean isEmpty() throws TemplateModelException;
+    boolean isEmpty() throws TemplateException;
 
 }

http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/d73da6da/freemarker-core/src/main/java/org/apache/freemarker/core/model/TemplateDateModel.java
----------------------------------------------------------------------
diff --git a/freemarker-core/src/main/java/org/apache/freemarker/core/model/TemplateDateModel.java b/freemarker-core/src/main/java/org/apache/freemarker/core/model/TemplateDateModel.java
index 024dc8e..df5db95 100644
--- a/freemarker-core/src/main/java/org/apache/freemarker/core/model/TemplateDateModel.java
+++ b/freemarker-core/src/main/java/org/apache/freemarker/core/model/TemplateDateModel.java
@@ -24,6 +24,8 @@ import java.util.Collections;
 import java.util.Date;
 import java.util.List;
 
+import org.apache.freemarker.core.TemplateException;
+
 /**
  * "date", "time" and "date-time" template language data types: corresponds to {@link java.util.Date}. Contrary to Java,
  * FreeMarker distinguishes date (no time part), time and date-time values.
@@ -62,7 +64,7 @@ public interface TemplateDateModel extends TemplateModel {
     /**
      * Returns the date value. The return value must not be {@code null}.
      */
-    Date getAsDate() throws TemplateModelException;
+    Date getAsDate() throws TemplateException;
 
     /**
      * Returns the type of the date. It can be any of {@link #TIME}, 

http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/d73da6da/freemarker-core/src/main/java/org/apache/freemarker/core/model/TemplateHashModel.java
----------------------------------------------------------------------
diff --git a/freemarker-core/src/main/java/org/apache/freemarker/core/model/TemplateHashModel.java b/freemarker-core/src/main/java/org/apache/freemarker/core/model/TemplateHashModel.java
index f60ce79..8125233 100644
--- a/freemarker-core/src/main/java/org/apache/freemarker/core/model/TemplateHashModel.java
+++ b/freemarker-core/src/main/java/org/apache/freemarker/core/model/TemplateHashModel.java
@@ -19,6 +19,8 @@
 
 package org.apache.freemarker.core.model;
 
+import org.apache.freemarker.core.TemplateException;
+
 /**
  * "hash" template language data type: an object that contains other objects accessible through string keys
  * (sub-variable names).
@@ -37,7 +39,7 @@ public interface TemplateHashModel extends TemplateModel {
      * @return the <tt>TemplateModel</tt> referred to by the key,
      * or null if not found.
      */
-    TemplateModel get(String key) throws TemplateModelException;
+    TemplateModel get(String key) throws TemplateException;
 
-    boolean isEmpty() throws TemplateModelException;
+    boolean isEmpty() throws TemplateException;
 }

http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/d73da6da/freemarker-core/src/main/java/org/apache/freemarker/core/model/TemplateHashModelEx.java
----------------------------------------------------------------------
diff --git a/freemarker-core/src/main/java/org/apache/freemarker/core/model/TemplateHashModelEx.java b/freemarker-core/src/main/java/org/apache/freemarker/core/model/TemplateHashModelEx.java
index c95a21d..cd2c0ee 100644
--- a/freemarker-core/src/main/java/org/apache/freemarker/core/model/TemplateHashModelEx.java
+++ b/freemarker-core/src/main/java/org/apache/freemarker/core/model/TemplateHashModelEx.java
@@ -19,6 +19,7 @@
 
 package org.apache.freemarker.core.model;
 
+import org.apache.freemarker.core.TemplateException;
 import org.apache.freemarker.core.model.impl.SimpleHash;
 
 /**
@@ -34,18 +35,18 @@ public interface TemplateHashModelEx extends TemplateHashModel {
     /**
      * @return the number of key/value mappings in the hash.
      */
-    int size() throws TemplateModelException;
+    int size() throws TemplateException;
 
     /**
      * @return a collection containing the keys in the hash. Every element of 
      *      the returned collection must implement the {@link TemplateScalarModel}
      *      (as the keys of hashes are always strings).
      */
-    TemplateCollectionModel keys() throws TemplateModelException;
+    TemplateCollectionModel keys() throws TemplateException;
 
     /**
      * @return a collection containing the values in the hash. The elements of the
      * returned collection can be any kind of {@link TemplateModel}-s.
      */
-    TemplateCollectionModel values() throws TemplateModelException;
+    TemplateCollectionModel values() throws TemplateException;
 }

http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/d73da6da/freemarker-core/src/main/java/org/apache/freemarker/core/model/TemplateHashModelEx2.java
----------------------------------------------------------------------
diff --git a/freemarker-core/src/main/java/org/apache/freemarker/core/model/TemplateHashModelEx2.java b/freemarker-core/src/main/java/org/apache/freemarker/core/model/TemplateHashModelEx2.java
index 6980c82..cf8cee4 100644
--- a/freemarker-core/src/main/java/org/apache/freemarker/core/model/TemplateHashModelEx2.java
+++ b/freemarker-core/src/main/java/org/apache/freemarker/core/model/TemplateHashModelEx2.java
@@ -21,6 +21,8 @@ package org.apache.freemarker.core.model;
 import java.util.Iterator;
 import java.util.NoSuchElementException;
 
+import org.apache.freemarker.core.TemplateException;
+
 /**
  * Adds key-value pair listing capability to {@link TemplateHashModelEx}. While in many cases that can also be achieved
  * with {@link #keys()} and then {@link #get(String)}, that has some problems. One is that {@link #get(String)} only
@@ -32,7 +34,7 @@ public interface TemplateHashModelEx2 extends TemplateHashModelEx {
     /**
      * @return The iterator that walks through the key-value pairs in the hash. Not {@code null}. 
      */
-    KeyValuePairIterator keyValuePairIterator() throws TemplateModelException;
+    KeyValuePairIterator keyValuePairIterator() throws TemplateException;
     
     /**
      * A key-value pair in a hash; used for {@link KeyValuePairIterator}.
@@ -42,17 +44,17 @@ public interface TemplateHashModelEx2 extends TemplateHashModelEx {
         /**
          * @return Any type of {@link TemplateModel}, maybe {@code null} (if the hash entry key is {@code null}).
          */
-        TemplateModel getKey() throws TemplateModelException;
+        TemplateModel getKey() throws TemplateException;
         
         /**
          * @return Any type of {@link TemplateModel}, maybe {@code null} (if the hash entry value is {@code null}).
          */
-        TemplateModel getValue() throws TemplateModelException;
+        TemplateModel getValue() throws TemplateException;
     }
     
     /**
      * Iterates over the key-value pairs in a hash. This is very similar to an {@link Iterator}, but has a fixed item
-     * type, can throw {@link TemplateModelException}-s, and has no {@code remove()} method. 
+     * type, can throw {@link TemplateException}-s, and has no {@code remove()} method.
      */
     interface KeyValuePairIterator {
 
@@ -61,7 +63,7 @@ public interface TemplateHashModelEx2 extends TemplateHashModelEx {
         /**
          * Similar to {@link Iterator#hasNext()}.
          */
-        boolean hasNext() throws TemplateModelException;
+        boolean hasNext() throws TemplateException;
         
         /**
          * Similar to {@link Iterator#next()}.
@@ -70,7 +72,7 @@ public interface TemplateHashModelEx2 extends TemplateHashModelEx {
          * 
          * @throws NoSuchElementException
          */
-        KeyValuePair next() throws TemplateModelException;
+        KeyValuePair next() throws TemplateException;
     }
     
 }

http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/d73da6da/freemarker-core/src/main/java/org/apache/freemarker/core/model/TemplateModelException.java
----------------------------------------------------------------------
diff --git a/freemarker-core/src/main/java/org/apache/freemarker/core/model/TemplateModelException.java b/freemarker-core/src/main/java/org/apache/freemarker/core/model/TemplateModelException.java
deleted file mode 100644
index c9d6aa9..0000000
--- a/freemarker-core/src/main/java/org/apache/freemarker/core/model/TemplateModelException.java
+++ /dev/null
@@ -1,113 +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.model;
-
-import org.apache.freemarker.core.Environment;
-import org.apache.freemarker.core.TemplateException;
-import org.apache.freemarker.core._ErrorDescriptionBuilder;
-
-/**
- * {@link ObjectWrapper}-s may throw this when wrapping/unwrapping fails, or {@link TemplateModel} methods throw this
- * if the requested data can't be retrieved. {@link TemplateCallableModel}-s should typically throw
- * {@link TemplateException} instead (like when a required argument is missing).
- */
-public class TemplateModelException extends TemplateException {
-
-    /**
-     * Constructs a <tt>TemplateModelException</tt> with no
-     * specified detail message.
-     */
-    public TemplateModelException() {
-        this(null, null);
-    }
-
-    /**
-     * Constructs a <tt>TemplateModelException</tt> with the
-     * specified detail message.
-     *
-     * @param description the detail message.
-     */
-    public TemplateModelException(String description) {
-        this(description, null);
-    }
-
-    /**
-     * The same as {@link #TemplateModelException(Throwable)}; it's exists only for binary
-     * backward-compatibility.
-     */
-    public TemplateModelException(Exception cause) {
-        this(null, cause);
-    }
-
-    /**
-     * Constructs a <tt>TemplateModelException</tt> with the given underlying
-     * Exception, but no detail message.
-     *
-     * @param cause the underlying {@link Exception} that caused this
-     * exception to be raised
-     */
-    public TemplateModelException(Throwable cause) {
-        this(null, cause);
-    }
-
-    
-    /**
-     * The same as {@link #TemplateModelException(String, Throwable)}; it's exists only for binary
-     * backward-compatibility.
-     */
-    public TemplateModelException(String description, Exception cause) {
-        super(description, cause, null);
-    }
-
-    /**
-     * Constructs a TemplateModelException with both a description of the error
-     * that occurred and the underlying Exception that caused this exception
-     * to be raised.
-     *
-     * @param description the description of the error that occurred
-     * @param cause the underlying {@link Exception} that caused this
-     * exception to be raised
-     */
-    public TemplateModelException(String description, Throwable cause) {
-        super(description, cause, null);
-    }
-
-    /**
-     * Don't use this; this is to be used internally by FreeMarker.
-     * @param preventAmbiguity its value is ignored; it's only to prevent constructor selection ambiguities for
-     *     backward-compatibility
-     */
-    protected TemplateModelException(Throwable cause, Environment env, String description,
-            boolean preventAmbiguity) {
-        super(description, cause, env);
-    }
-    
-    /**
-     * Don't use this; this is to be used internally by FreeMarker.
-     * @param preventAmbiguity its value is ignored; it's only to prevent constructor selection ambiguities for
-     *     backward-compatibility
-     */
-    protected TemplateModelException(
-            Throwable cause, Environment env, _ErrorDescriptionBuilder descriptionBuilder,
-            boolean preventAmbiguity) {
-        super(cause, env, null, descriptionBuilder);
-    }
-    
-}

http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/d73da6da/freemarker-core/src/main/java/org/apache/freemarker/core/model/TemplateModelIterator.java
----------------------------------------------------------------------
diff --git a/freemarker-core/src/main/java/org/apache/freemarker/core/model/TemplateModelIterator.java b/freemarker-core/src/main/java/org/apache/freemarker/core/model/TemplateModelIterator.java
index 04c8de1..cd24cbb 100644
--- a/freemarker-core/src/main/java/org/apache/freemarker/core/model/TemplateModelIterator.java
+++ b/freemarker-core/src/main/java/org/apache/freemarker/core/model/TemplateModelIterator.java
@@ -19,6 +19,8 @@
 
 package org.apache.freemarker.core.model;
 
+import org.apache.freemarker.core.TemplateException;
+
 /**
  * Used to iterate over a set of template models <em>once</em>; usually returned from
  * {@link TemplateCollectionModel#iterator()}. Note that it's not a {@link TemplateModel}.
@@ -29,14 +31,14 @@ public interface TemplateModelIterator {
 
     /**
      * Returns the next model.
-     * @throws TemplateModelException if the next model can not be retrieved
+     * @throws TemplateException if the next model can not be retrieved
      *   (i.e. because the iterator is exhausted).
      */
-    TemplateModel next() throws TemplateModelException;
+    TemplateModel next() throws TemplateException;
 
     /**
      * @return whether there are any more items to iterate over.
      */
-    boolean hasNext() throws TemplateModelException;
+    boolean hasNext() throws TemplateException;
 
 }

http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/d73da6da/freemarker-core/src/main/java/org/apache/freemarker/core/model/TemplateModelWithAPISupport.java
----------------------------------------------------------------------
diff --git a/freemarker-core/src/main/java/org/apache/freemarker/core/model/TemplateModelWithAPISupport.java b/freemarker-core/src/main/java/org/apache/freemarker/core/model/TemplateModelWithAPISupport.java
index 8ca2233..fbc0d00 100644
--- a/freemarker-core/src/main/java/org/apache/freemarker/core/model/TemplateModelWithAPISupport.java
+++ b/freemarker-core/src/main/java/org/apache/freemarker/core/model/TemplateModelWithAPISupport.java
@@ -19,6 +19,8 @@
 
 package org.apache.freemarker.core.model;
 
+import org.apache.freemarker.core.TemplateException;
+
 /**
  * <b>Experimental - subject to change:</b> A {@link TemplateModel} on which the {@code ?api} operation can be applied.
  * 
@@ -32,6 +34,6 @@ public interface TemplateModelWithAPISupport extends TemplateModel {
      * Returns the model that exposes the (Java) API of the value. This is usually implemented by delegating to
      * {@link ObjectWrapperWithAPISupport#wrapAsAPI(Object)}.
      */
-    TemplateModel getAPI() throws TemplateModelException;
+    TemplateModel getAPI() throws TemplateException;
 
 }

http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/d73da6da/freemarker-core/src/main/java/org/apache/freemarker/core/model/TemplateNodeModel.java
----------------------------------------------------------------------
diff --git a/freemarker-core/src/main/java/org/apache/freemarker/core/model/TemplateNodeModel.java b/freemarker-core/src/main/java/org/apache/freemarker/core/model/TemplateNodeModel.java
index d5df64c..81a64b2 100644
--- a/freemarker-core/src/main/java/org/apache/freemarker/core/model/TemplateNodeModel.java
+++ b/freemarker-core/src/main/java/org/apache/freemarker/core/model/TemplateNodeModel.java
@@ -19,6 +19,8 @@
 
 package org.apache.freemarker.core.model;
 
+import org.apache.freemarker.core.TemplateException;
+
 /**
  * "node" template language data type: an object that is a node in a tree.
  * A tree of nodes can be recursively <em>visited</em> using the &lt;#visit...&gt; and &lt;#recurse...&gt;
@@ -37,14 +39,14 @@ public interface TemplateNodeModel extends TemplateModel {
      * @return the parent of this node or null, in which case
      * this node is the root of the tree.
      */
-    TemplateNodeModel getParentNode() throws TemplateModelException;
+    TemplateNodeModel getParentNode() throws TemplateException;
     
     /**
      * @return a sequence containing this node's children.
      * If the returned value is null or empty, this is essentially 
      * a leaf node.
      */
-    TemplateSequenceModel getChildNodes() throws TemplateModelException;
+    TemplateSequenceModel getChildNodes() throws TemplateException;
 
     /**
      * @return a String that is used to determine the processing
@@ -54,7 +56,7 @@ public interface TemplateNodeModel extends TemplateModel {
      * returns "@text" for text nodes, "@pi" for processing instructions,
      * and so on.
      */    
-    String getNodeName() throws TemplateModelException;
+    String getNodeName() throws TemplateException;
     
     /**
      * @return a String describing the <em>type</em> of node this is.
@@ -63,7 +65,7 @@ public interface TemplateNodeModel extends TemplateModel {
      * trees could return whatever it appropriate for that application. It
      * can be null, if you don't want to use node-types.
      */
-    String getNodeType() throws TemplateModelException;
+    String getNodeType() throws TemplateException;
     
     
     /**
@@ -72,5 +74,5 @@ public interface TemplateNodeModel extends TemplateModel {
      * not XML-related, it will almost certainly be null. Even 
      * for XML nodes, this will often be null.
      */
-    String getNodeNamespace() throws TemplateModelException;
+    String getNodeNamespace() throws TemplateException;
 }

http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/d73da6da/freemarker-core/src/main/java/org/apache/freemarker/core/model/TemplateNodeModelEx.java
----------------------------------------------------------------------
diff --git a/freemarker-core/src/main/java/org/apache/freemarker/core/model/TemplateNodeModelEx.java b/freemarker-core/src/main/java/org/apache/freemarker/core/model/TemplateNodeModelEx.java
index 41d9d42..3ecad00 100644
--- a/freemarker-core/src/main/java/org/apache/freemarker/core/model/TemplateNodeModelEx.java
+++ b/freemarker-core/src/main/java/org/apache/freemarker/core/model/TemplateNodeModelEx.java
@@ -19,6 +19,8 @@
 
 package org.apache.freemarker.core.model;
 
+import org.apache.freemarker.core.TemplateException;
+
 /**
  * A {@link TemplateNodeModel} that supports navigating to the previous and next sibling nodes.
  */
@@ -27,10 +29,10 @@ public interface TemplateNodeModelEx extends TemplateNodeModel {
     /**
      * @return The immediate previous sibling of this node, or {@code null} if there's no such node.
      */
-    TemplateNodeModelEx getPreviousSibling() throws TemplateModelException;
+    TemplateNodeModelEx getPreviousSibling() throws TemplateException;
 
     /**
      * @return The immediate next sibling of this node, or {@code null} if there's no such node.
      */
-    TemplateNodeModelEx getNextSibling() throws TemplateModelException;
+    TemplateNodeModelEx getNextSibling() throws TemplateException;
 }

http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/d73da6da/freemarker-core/src/main/java/org/apache/freemarker/core/model/TemplateNumberModel.java
----------------------------------------------------------------------
diff --git a/freemarker-core/src/main/java/org/apache/freemarker/core/model/TemplateNumberModel.java b/freemarker-core/src/main/java/org/apache/freemarker/core/model/TemplateNumberModel.java
index c1df97f..8e06bf1 100644
--- a/freemarker-core/src/main/java/org/apache/freemarker/core/model/TemplateNumberModel.java
+++ b/freemarker-core/src/main/java/org/apache/freemarker/core/model/TemplateNumberModel.java
@@ -19,6 +19,7 @@
 
 package org.apache.freemarker.core.model;
 
+import org.apache.freemarker.core.TemplateException;
 import org.apache.freemarker.core.arithmetic.ArithmeticEngine;
 import org.apache.freemarker.core.model.impl.SimpleNumber;
 
@@ -42,6 +43,6 @@ public interface TemplateNumberModel extends TemplateModel {
      *
      * @return the {@link Number} instance associated with this number model.
      */
-    Number getAsNumber() throws TemplateModelException;
+    Number getAsNumber() throws TemplateException;
     
 }

http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/d73da6da/freemarker-core/src/main/java/org/apache/freemarker/core/model/TemplateScalarModel.java
----------------------------------------------------------------------
diff --git a/freemarker-core/src/main/java/org/apache/freemarker/core/model/TemplateScalarModel.java b/freemarker-core/src/main/java/org/apache/freemarker/core/model/TemplateScalarModel.java
index b76a097..b34b21b 100644
--- a/freemarker-core/src/main/java/org/apache/freemarker/core/model/TemplateScalarModel.java
+++ b/freemarker-core/src/main/java/org/apache/freemarker/core/model/TemplateScalarModel.java
@@ -19,6 +19,7 @@
 
 package org.apache.freemarker.core.model;
 
+import org.apache.freemarker.core.TemplateException;
 import org.apache.freemarker.core.model.impl.SimpleScalar;
 
 /**
@@ -40,6 +41,6 @@ public interface TemplateScalarModel extends TemplateModel {
      * Objects of this type should be immutable, that is, calling {@link #getAsString()} should always return the same
      * value as for the first time.
      */
-    String getAsString() throws TemplateModelException;
+    String getAsString() throws TemplateException;
 
 }

http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/d73da6da/freemarker-core/src/main/java/org/apache/freemarker/core/model/TemplateSequenceModel.java
----------------------------------------------------------------------
diff --git a/freemarker-core/src/main/java/org/apache/freemarker/core/model/TemplateSequenceModel.java b/freemarker-core/src/main/java/org/apache/freemarker/core/model/TemplateSequenceModel.java
index 0533fcf..d9dc6c6 100644
--- a/freemarker-core/src/main/java/org/apache/freemarker/core/model/TemplateSequenceModel.java
+++ b/freemarker-core/src/main/java/org/apache/freemarker/core/model/TemplateSequenceModel.java
@@ -19,6 +19,8 @@
 
 package org.apache.freemarker.core.model;
 
+import org.apache.freemarker.core.TemplateException;
+
 /**
  * "sequence" template language data type; an object that contains other objects accessible through an integer 0-based
  * index.
@@ -41,10 +43,10 @@ public interface TemplateSequenceModel extends TemplateModel {
      *         a bad index will not remain hidden, unless the default value for that case was also specified in the
      *         template.
      */
-    TemplateModel get(int index) throws TemplateModelException;
+    TemplateModel get(int index) throws TemplateException;
 
     /**
      * @return the number of items in the list.
      */
-    int size() throws TemplateModelException;
+    int size() throws TemplateException;
 }

http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/d73da6da/freemarker-core/src/main/java/org/apache/freemarker/core/model/WrappingTemplateModel.java
----------------------------------------------------------------------
diff --git a/freemarker-core/src/main/java/org/apache/freemarker/core/model/WrappingTemplateModel.java b/freemarker-core/src/main/java/org/apache/freemarker/core/model/WrappingTemplateModel.java
index 206d9d4..d6254e9 100644
--- a/freemarker-core/src/main/java/org/apache/freemarker/core/model/WrappingTemplateModel.java
+++ b/freemarker-core/src/main/java/org/apache/freemarker/core/model/WrappingTemplateModel.java
@@ -52,10 +52,10 @@ abstract public class WrappingTemplateModel {
      * wrapper.
      * @param obj the object to wrap
      * @return the template model that wraps the object
-     * @throws TemplateModelException if the wrapper does not know how to
+     * @throws ObjectWrappingException if the wrapper does not know how to
      * wrap the passed object.
      */
-    protected final TemplateModel wrap(Object obj) throws TemplateModelException {
+    protected final TemplateModel wrap(Object obj) throws ObjectWrappingException {
             return objectWrapper.wrap(obj);
     }
     

http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/d73da6da/freemarker-core/src/main/java/org/apache/freemarker/core/model/impl/ArgumentTypes.java
----------------------------------------------------------------------
diff --git a/freemarker-core/src/main/java/org/apache/freemarker/core/model/impl/ArgumentTypes.java b/freemarker-core/src/main/java/org/apache/freemarker/core/model/impl/ArgumentTypes.java
index cf05a09..20a2c14 100644
--- a/freemarker-core/src/main/java/org/apache/freemarker/core/model/impl/ArgumentTypes.java
+++ b/freemarker-core/src/main/java/org/apache/freemarker/core/model/impl/ArgumentTypes.java
@@ -24,8 +24,8 @@ import java.util.Iterator;
 import java.util.LinkedList;
 import java.util.List;
 
+import org.apache.freemarker.core.TemplateException;
 import org.apache.freemarker.core.model.TemplateModel;
-import org.apache.freemarker.core.model.TemplateModelException;
 import org.apache.freemarker.core.util.BugException;
 import org.apache.freemarker.core.util._ClassUtils;
 
@@ -561,7 +561,7 @@ final class ArgumentTypes {
         }
 
         @Override
-        TemplateModel invokeMethod(DefaultObjectWrapper ow, Object obj, Object[] args) throws TemplateModelException,
+        TemplateModel invokeMethod(DefaultObjectWrapper ow, Object obj, Object[] args) throws TemplateException,
                 InvocationTargetException, IllegalAccessException {
             convertArgsToReflectionCompatible(ow, args);
             return callableMemberDesc.invokeMethod(ow, obj, args);
@@ -569,7 +569,7 @@ final class ArgumentTypes {
 
         @Override
         Object invokeConstructor(DefaultObjectWrapper ow, Object[] args) throws IllegalArgumentException,
-                InstantiationException, IllegalAccessException, InvocationTargetException, TemplateModelException {
+                InstantiationException, IllegalAccessException, InvocationTargetException, TemplateException {
             convertArgsToReflectionCompatible(ow, args);
             return callableMemberDesc.invokeConstructor(ow, args);
         }
@@ -604,7 +604,7 @@ final class ArgumentTypes {
             return callableMemberDesc.getName();
         }
 
-        private void convertArgsToReflectionCompatible(DefaultObjectWrapper ow, Object[] args) throws TemplateModelException {
+        private void convertArgsToReflectionCompatible(DefaultObjectWrapper ow, Object[] args) throws TemplateException {
             Class<?>[] paramTypes = callableMemberDesc.getParamTypes();
             int ln = paramTypes.length;
             for (int i = 0; i < ln; i++) {

http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/d73da6da/freemarker-core/src/main/java/org/apache/freemarker/core/model/impl/BeanModel.java
----------------------------------------------------------------------
diff --git a/freemarker-core/src/main/java/org/apache/freemarker/core/model/impl/BeanModel.java b/freemarker-core/src/main/java/org/apache/freemarker/core/model/impl/BeanModel.java
index 0baf851..761122f 100644
--- a/freemarker-core/src/main/java/org/apache/freemarker/core/model/impl/BeanModel.java
+++ b/freemarker-core/src/main/java/org/apache/freemarker/core/model/impl/BeanModel.java
@@ -32,15 +32,15 @@ import java.util.List;
 import java.util.Map;
 import java.util.Set;
 
-import org.apache.freemarker.core._DelayedTemplateLanguageTypeDescription;
+import org.apache.freemarker.core.TemplateException;
 import org.apache.freemarker.core._DelayedJQuote;
-import org.apache.freemarker.core._TemplateModelException;
+import org.apache.freemarker.core._DelayedTemplateLanguageTypeDescription;
 import org.apache.freemarker.core.model.AdapterTemplateModel;
+import org.apache.freemarker.core.model.ObjectWrappingException;
 import org.apache.freemarker.core.model.TemplateCollectionModel;
 import org.apache.freemarker.core.model.TemplateFunctionModel;
 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.TemplateModelWithAPISupport;
 import org.apache.freemarker.core.model.TemplateScalarModel;
@@ -124,12 +124,12 @@ public class BeanModel
      * then <tt>non-void-return-type get(java.lang.Object)</tt>, or 
      * alternatively (if the wrapped object is a resource bundle) 
      * <tt>Object get(java.lang.String)</tt>.
-     * @throws TemplateModelException if there was no property nor method nor
+     * @throws TemplateException if there was no property nor method nor
      * a generic <tt>get</tt> method to invoke.
      */
     @Override
     public TemplateModel get(String key)
-        throws TemplateModelException {
+        throws TemplateException {
         Class<?> clazz = object.getClass();
         Map<Object, Object> classInfo = wrapper.getClassIntrospector().get(clazz);
         TemplateModel retval = null;
@@ -148,10 +148,10 @@ public class BeanModel
                 retval = wrapper.wrap(null);
             }
             return retval;
-        } catch (TemplateModelException e) {
+        } catch (TemplateException e) {
             throw e;
         } catch (Exception e) {
-            throw new _TemplateModelException(e,
+            throw new TemplateException(e,
                     "An error has occurred when reading existing sub-variable ", new _DelayedJQuote(key),
                     "; see cause exception! The type of the containing value was: ",
                     new _DelayedTemplateLanguageTypeDescription(this)
@@ -168,7 +168,7 @@ public class BeanModel
     }
     
     private TemplateModel invokeThroughDescriptor(Object desc, Map<Object, Object> classInfo)
-            throws IllegalAccessException, InvocationTargetException, TemplateModelException {
+            throws IllegalAccessException, InvocationTargetException, TemplateException {
         // See if this particular instance has a cached implementation for the requested feature descriptor
         TemplateModel cachedModel;
         synchronized (this) {
@@ -227,7 +227,7 @@ public class BeanModel
 
     protected TemplateModel invokeGenericGet(Map/*<Object, Object>*/ classInfo, Class<?> clazz, String key)
             throws IllegalAccessException, InvocationTargetException,
-        TemplateModelException {
+        TemplateException {
         Method genericGet = (Method) classInfo.get(ClassIntrospector.GENERIC_GET_KEY);
         if (genericGet == null) {
             return UNKNOWN;
@@ -236,13 +236,12 @@ public class BeanModel
         return wrapper.invokeMethod(object, genericGet, new Object[] { key });
     }
 
-    protected TemplateModel wrap(Object obj)
-    throws TemplateModelException {
+    protected TemplateModel wrap(Object obj) throws ObjectWrappingException {
         return wrapper.getOuterIdentity().wrap(obj);
     }
     
     protected Object unwrap(TemplateModel model)
-    throws TemplateModelException {
+    throws TemplateException {
         return wrapper.unwrap(model);
     }
 
@@ -294,7 +293,7 @@ public class BeanModel
     }
 
     @Override
-    public TemplateCollectionModel values() throws TemplateModelException {
+    public TemplateCollectionModel values() throws TemplateException {
         List<Object> values = new ArrayList<>(size());
         TemplateModelIterator it = keys().iterator();
         while (it.hasNext()) {
@@ -320,7 +319,7 @@ public class BeanModel
     }
 
     @Override
-    public TemplateModel getAPI() throws TemplateModelException {
+    public TemplateModel getAPI() throws TemplateException {
         return wrapper.wrapAsAPI(object);
     }
     

http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/d73da6da/freemarker-core/src/main/java/org/apache/freemarker/core/model/impl/CallableMemberDescriptor.java
----------------------------------------------------------------------
diff --git a/freemarker-core/src/main/java/org/apache/freemarker/core/model/impl/CallableMemberDescriptor.java b/freemarker-core/src/main/java/org/apache/freemarker/core/model/impl/CallableMemberDescriptor.java
index bbaf6bd..398a3f9 100644
--- a/freemarker-core/src/main/java/org/apache/freemarker/core/model/impl/CallableMemberDescriptor.java
+++ b/freemarker-core/src/main/java/org/apache/freemarker/core/model/impl/CallableMemberDescriptor.java
@@ -23,8 +23,8 @@ import java.lang.reflect.Constructor;
 import java.lang.reflect.InvocationTargetException;
 import java.lang.reflect.Method;
 
+import org.apache.freemarker.core.TemplateException;
 import org.apache.freemarker.core.model.TemplateModel;
-import org.apache.freemarker.core.model.TemplateModelException;
 
 /**
  * Packs a {@link Method} or {@link Constructor} together with its parameter types. The actual
@@ -35,11 +35,11 @@ import org.apache.freemarker.core.model.TemplateModelException;
 abstract class CallableMemberDescriptor extends MaybeEmptyCallableMemberDescriptor {
 
     abstract TemplateModel invokeMethod(DefaultObjectWrapper ow, Object obj, Object[] args)
-            throws TemplateModelException, InvocationTargetException, IllegalAccessException;
+            throws TemplateException, InvocationTargetException, IllegalAccessException;
 
     abstract Object invokeConstructor(DefaultObjectWrapper ow, Object[] args)
             throws IllegalArgumentException, InstantiationException, IllegalAccessException, InvocationTargetException,
-            TemplateModelException;
+            TemplateException;
     
     abstract String getDeclaration();
     

http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/d73da6da/freemarker-core/src/main/java/org/apache/freemarker/core/model/impl/ClassBasedModelFactory.java
----------------------------------------------------------------------
diff --git a/freemarker-core/src/main/java/org/apache/freemarker/core/model/impl/ClassBasedModelFactory.java b/freemarker-core/src/main/java/org/apache/freemarker/core/model/impl/ClassBasedModelFactory.java
index c866d65..ac055b4 100644
--- a/freemarker-core/src/main/java/org/apache/freemarker/core/model/impl/ClassBasedModelFactory.java
+++ b/freemarker-core/src/main/java/org/apache/freemarker/core/model/impl/ClassBasedModelFactory.java
@@ -24,9 +24,10 @@ import java.util.Map;
 import java.util.Set;
 import java.util.concurrent.ConcurrentHashMap;
 
+import org.apache.freemarker.core.TemplateException;
+import org.apache.freemarker.core._DelayedJQuote;
 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.util._ClassUtils;
 
 /**
@@ -43,19 +44,20 @@ abstract class ClassBasedModelFactory implements TemplateHashModel {
     }
 
     @Override
-    public TemplateModel get(String key) throws TemplateModelException {
+    public TemplateModel get(String key) throws TemplateException {
         try {
             return getInternal(key);
         } catch (Exception e) {
-            if (e instanceof TemplateModelException) {
-                throw (TemplateModelException) e;
+            if (e instanceof TemplateException) {
+                throw (TemplateException) e;
             } else {
-                throw new TemplateModelException(e);
+                throw new TemplateException(e,
+                        "Failed to get valeu for key ", new _DelayedJQuote(key), "; see cause exception.");
             }
         }
     }
 
-    private TemplateModel getInternal(String key) throws TemplateModelException, ClassNotFoundException {
+    private TemplateModel getInternal(String key) throws TemplateException, ClassNotFoundException {
         {
             TemplateModel model = (TemplateModel) cache.get(key);
             if (model != null) return model;
@@ -139,7 +141,7 @@ abstract class ClassBasedModelFactory implements TemplateHashModel {
     }
     
     protected abstract TemplateModel createModel(Class clazz) 
-    throws TemplateModelException;
+    throws TemplateException;
     
     protected DefaultObjectWrapper getWrapper() {
         return wrapper;

http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/d73da6da/freemarker-core/src/main/java/org/apache/freemarker/core/model/impl/CollectionAdapter.java
----------------------------------------------------------------------
diff --git a/freemarker-core/src/main/java/org/apache/freemarker/core/model/impl/CollectionAdapter.java b/freemarker-core/src/main/java/org/apache/freemarker/core/model/impl/CollectionAdapter.java
index e9860ab..10f2091 100644
--- a/freemarker-core/src/main/java/org/apache/freemarker/core/model/impl/CollectionAdapter.java
+++ b/freemarker-core/src/main/java/org/apache/freemarker/core/model/impl/CollectionAdapter.java
@@ -23,10 +23,10 @@ import java.util.AbstractCollection;
 import java.util.Collection;
 import java.util.Iterator;
 
+import org.apache.freemarker.core.TemplateException;
 import org.apache.freemarker.core.model.TemplateCollectionModel;
 import org.apache.freemarker.core.model.TemplateModel;
 import org.apache.freemarker.core.model.TemplateModelAdapter;
-import org.apache.freemarker.core.model.TemplateModelException;
 import org.apache.freemarker.core.model.TemplateModelIterator;
 import org.apache.freemarker.core.util.UndeclaredThrowableException;
 
@@ -62,7 +62,7 @@ class CollectionAdapter extends AbstractCollection implements TemplateModelAdapt
                 public boolean hasNext() {
                     try {
                         return i.hasNext();
-                    } catch (TemplateModelException e) {
+                    } catch (TemplateException e) {
                         throw new UndeclaredThrowableException(e);
                     }
                 }
@@ -71,7 +71,7 @@ class CollectionAdapter extends AbstractCollection implements TemplateModelAdapt
                 public Object next() {
                     try {
                         return wrapper.unwrap(i.next());
-                    } catch (TemplateModelException e) {
+                    } catch (TemplateException e) {
                         throw new UndeclaredThrowableException(e);
                     }
                 }
@@ -81,7 +81,7 @@ class CollectionAdapter extends AbstractCollection implements TemplateModelAdapt
                     throw new UnsupportedOperationException();
                 }
             };
-        } catch (TemplateModelException e) {
+        } catch (TemplateException e) {
             throw new UndeclaredThrowableException(e);
         }
     }



Mime
View raw message