Repository: incubator-freemarker
Updated Branches:
  refs/heads/3 3f2743387 -> 22de04e9b


Got rid of _MiscTemplateException; merged internal constructors into 
TemplateException.


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

Branch: refs/heads/3
Commit: 22de04e9b90e837c176f8ba3aea75c90e1494cde
Parents: 3f27433
Author: ddekany <ddek...@apache.org>
Authored: Tue Aug 8 22:18:34 2017 +0200
Committer: ddekany <ddek...@apache.org>
Committed: Tue Aug 8 22:18:34 2017 +0200

----------------------------------------------------------------------
 .../apache/freemarker/core/ASTDirImport.java    |   4 +-
 .../apache/freemarker/core/ASTDirInclude.java   |   6 +-
 .../org/apache/freemarker/core/ASTDirItems.java |   2 +-
 .../org/apache/freemarker/core/ASTDirList.java  |   4 +-
 .../apache/freemarker/core/ASTDirRecurse.java   |   2 +-
 .../org/apache/freemarker/core/ASTDirSep.java   |   2 +-
 .../apache/freemarker/core/ASTDirSetting.java   |   2 +-
 .../org/apache/freemarker/core/ASTDirVisit.java |   2 +-
 .../freemarker/core/ASTDynamicTopLevelCall.java |   6 +-
 .../freemarker/core/ASTExpArithmetic.java       |   4 +-
 .../freemarker/core/ASTExpBuiltInVariable.java  |   2 +-
 .../freemarker/core/ASTExpDynamicKeyName.java   |  14 +--
 .../freemarker/core/ASTExpListLiteral.java      |   2 +-
 .../apache/freemarker/core/ASTExpVariable.java  |   2 +-
 .../core/BuiltInForNestedContentParameter.java  |   2 +-
 .../freemarker/core/BuiltInsForDates.java       |   2 +-
 .../core/BuiltInsForMultipleTypes.java          |   4 +-
 .../core/BuiltInsForStringsBasic.java           |   2 +-
 .../freemarker/core/BuiltInsForStringsMisc.java |  12 +-
 .../core/BuiltInsWithParseTimeParameters.java   |   2 +-
 .../org/apache/freemarker/core/Environment.java |  24 ++--
 .../apache/freemarker/core/MessageUtils.java    |   6 +-
 .../freemarker/core/TemplateClassResolver.java  |   2 +-
 .../freemarker/core/TemplateException.java      | 119 ++++++++++++++++--
 .../apache/freemarker/core/_CallableUtils.java  |  12 +-
 .../org/apache/freemarker/core/_EvalUtils.java  |  20 +--
 .../freemarker/core/_MiscTemplateException.java | 124 -------------------
 .../impl/ConservativeArithmeticEngine.java      |   7 +-
 .../core/util/OptInTemplateClassResolver.java   |   7 +-
 .../apache/freemarker/servlet/IncludePage.java  |  14 +--
 .../freemarker/servlet/jsp/JspTagModelBase.java |   3 +-
 31 files changed, 193 insertions(+), 223 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/22de04e9/freemarker-core/src/main/java/org/apache/freemarker/core/ASTDirImport.java
----------------------------------------------------------------------
diff --git 
a/freemarker-core/src/main/java/org/apache/freemarker/core/ASTDirImport.java 
b/freemarker-core/src/main/java/org/apache/freemarker/core/ASTDirImport.java
index 79b320a..88cfeb5 100644
--- a/freemarker-core/src/main/java/org/apache/freemarker/core/ASTDirImport.java
+++ b/freemarker-core/src/main/java/org/apache/freemarker/core/ASTDirImport.java
@@ -51,7 +51,7 @@ final class ASTDirImport extends ASTDirective {
         try {
             fullImportedTemplateName = 
env.toFullTemplateName(getTemplate().getLookupName(), importedTemplateName);
         } catch (MalformedTemplateNameException e) {
-            throw new _MiscTemplateException(e, env,
+            throw new TemplateException(e, env,
                     "Malformed template name ", new 
_DelayedJQuote(e.getTemplateName()), ":\n",
                     e.getMalformednessDescription());
         }
@@ -59,7 +59,7 @@ final class ASTDirImport extends ASTDirective {
         try {
             env.importLib(fullImportedTemplateName, targetNsVarName);
         } catch (IOException e) {
-            throw new _MiscTemplateException(e, env,
+            throw new TemplateException(e, env,
                     "Template importing failed (for parameter value ",
                     new _DelayedJQuote(importedTemplateName),
                     "):\n", new _DelayedGetMessage(e));

http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/22de04e9/freemarker-core/src/main/java/org/apache/freemarker/core/ASTDirInclude.java
----------------------------------------------------------------------
diff --git 
a/freemarker-core/src/main/java/org/apache/freemarker/core/ASTDirInclude.java 
b/freemarker-core/src/main/java/org/apache/freemarker/core/ASTDirInclude.java
index 169541b..37cc017 100644
--- 
a/freemarker-core/src/main/java/org/apache/freemarker/core/ASTDirInclude.java
+++ 
b/freemarker-core/src/main/java/org/apache/freemarker/core/ASTDirInclude.java
@@ -68,7 +68,7 @@ final class ASTDirInclude extends ASTDirective {
         try {
             fullIncludedTemplateName = 
env.toFullTemplateName(getTemplate().getLookupName(), includedTemplateName);
         } catch (MalformedTemplateNameException e) {
-            throw new _MiscTemplateException(e, env,
+            throw new TemplateException(e, env,
                     "Malformed template name ", new 
_DelayedJQuote(e.getTemplateName()), ":\n",
                     e.getMalformednessDescription());
         }
@@ -86,7 +86,7 @@ final class ASTDirInclude extends ASTDirective {
         try {
             includedTemplate = 
env.getTemplateForInclusion(fullIncludedTemplateName, ignoreMissing);
         } catch (IOException e) {
-            throw new _MiscTemplateException(e, env,
+            throw new TemplateException(e, env,
                     "Template inclusion failed (for parameter value ",
                     new _DelayedJQuote(includedTemplateName),
                     "):\n", new _DelayedGetMessage(e));
@@ -149,7 +149,7 @@ final class ASTDirInclude extends ASTDirective {
         try {
            return _StringUtils.getYesNo(s);
         } catch (IllegalArgumentException iae) {
-            throw new _MiscTemplateException(exp,
+            throw new TemplateException(exp,
                      "Value must be boolean (or one of these strings: "
                      + "\"n\", \"no\", \"f\", \"false\", \"y\", \"yes\", 
\"t\", \"true\"), but it was ",
                      new _DelayedJQuote(s), ".");

http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/22de04e9/freemarker-core/src/main/java/org/apache/freemarker/core/ASTDirItems.java
----------------------------------------------------------------------
diff --git 
a/freemarker-core/src/main/java/org/apache/freemarker/core/ASTDirItems.java 
b/freemarker-core/src/main/java/org/apache/freemarker/core/ASTDirItems.java
index 0f2508b..cf85b77 100644
--- a/freemarker-core/src/main/java/org/apache/freemarker/core/ASTDirItems.java
+++ b/freemarker-core/src/main/java/org/apache/freemarker/core/ASTDirItems.java
@@ -47,7 +47,7 @@ class ASTDirItems extends ASTDirective {
         final IterationContext iterCtx = 
ASTDirList.findEnclosingIterationContext(env, null);
         if (iterCtx == null) {
             // The parser should prevent this situation
-            throw new _MiscTemplateException(env,
+            throw new TemplateException(env,
                     getASTNodeDescriptor(), " without iteration in context");
         }
         

http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/22de04e9/freemarker-core/src/main/java/org/apache/freemarker/core/ASTDirList.java
----------------------------------------------------------------------
diff --git 
a/freemarker-core/src/main/java/org/apache/freemarker/core/ASTDirList.java 
b/freemarker-core/src/main/java/org/apache/freemarker/core/ASTDirList.java
index 40da397..57120c2 100644
--- a/freemarker-core/src/main/java/org/apache/freemarker/core/ASTDirList.java
+++ b/freemarker-core/src/main/java/org/apache/freemarker/core/ASTDirList.java
@@ -104,7 +104,7 @@ final class ASTDirList extends ASTDirective {
      * @return The matching context or {@code null} if no such context exists.
      */
     static IterationContext findEnclosingIterationContext(Environment env, 
String nestedContentParamName)
-            throws _MiscTemplateException {
+            throws TemplateException {
         LocalContextStack ctxStack = env.getLocalContextStack();
         if (ctxStack != null) {
             for (int i = ctxStack.size() - 1; i >= 0; i--) {
@@ -232,7 +232,7 @@ final class ASTDirList extends ASTDirective {
                 throws TemplateException, IOException {
             try {
                 if (alreadyEntered) {
-                    throw new _MiscTemplateException(env,
+                    throw new TemplateException(env,
                             "The #items directive was already entered earlier 
for this listing.");
                 }
                 alreadyEntered = true;

http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/22de04e9/freemarker-core/src/main/java/org/apache/freemarker/core/ASTDirRecurse.java
----------------------------------------------------------------------
diff --git 
a/freemarker-core/src/main/java/org/apache/freemarker/core/ASTDirRecurse.java 
b/freemarker-core/src/main/java/org/apache/freemarker/core/ASTDirRecurse.java
index 7e7551d..17842ec 100644
--- 
a/freemarker-core/src/main/java/org/apache/freemarker/core/ASTDirRecurse.java
+++ 
b/freemarker-core/src/main/java/org/apache/freemarker/core/ASTDirRecurse.java
@@ -63,7 +63,7 @@ final class ASTDirRecurse extends ASTDirective {
                     throw new NonSequenceException(namespaces, nss, env);
                 } else {
                     // Should not occur
-                    throw new _MiscTemplateException(env, "Expecting a 
sequence of namespaces after \"using\"");
+                    throw new TemplateException(env, "Expecting a sequence of 
namespaces after \"using\"");
                 }
             }
         }

http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/22de04e9/freemarker-core/src/main/java/org/apache/freemarker/core/ASTDirSep.java
----------------------------------------------------------------------
diff --git 
a/freemarker-core/src/main/java/org/apache/freemarker/core/ASTDirSep.java 
b/freemarker-core/src/main/java/org/apache/freemarker/core/ASTDirSep.java
index ca2107d..9482f9c 100644
--- a/freemarker-core/src/main/java/org/apache/freemarker/core/ASTDirSep.java
+++ b/freemarker-core/src/main/java/org/apache/freemarker/core/ASTDirSep.java
@@ -36,7 +36,7 @@ class ASTDirSep extends ASTDirective {
         final IterationContext iterCtx = 
ASTDirList.findEnclosingIterationContext(env, null);
         if (iterCtx == null) {
             // The parser should prevent this situation
-            throw new _MiscTemplateException(env,
+            throw new TemplateException(env,
                     getASTNodeDescriptor(), " without iteration in context");
         }
         

http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/22de04e9/freemarker-core/src/main/java/org/apache/freemarker/core/ASTDirSetting.java
----------------------------------------------------------------------
diff --git 
a/freemarker-core/src/main/java/org/apache/freemarker/core/ASTDirSetting.java 
b/freemarker-core/src/main/java/org/apache/freemarker/core/ASTDirSetting.java
index 2217a18..d536779 100644
--- 
a/freemarker-core/src/main/java/org/apache/freemarker/core/ASTDirSetting.java
+++ 
b/freemarker-core/src/main/java/org/apache/freemarker/core/ASTDirSetting.java
@@ -119,7 +119,7 @@ final class ASTDirSetting extends ASTDirective {
         try {
             env.setSetting(key, strval);
         } catch (ConfigurationException e) {
-            throw new _MiscTemplateException(env, e.getMessage(), 
e.getCause());
+            throw new TemplateException(env, e.getMessage(), e.getCause());
         }
         return null;
     }

http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/22de04e9/freemarker-core/src/main/java/org/apache/freemarker/core/ASTDirVisit.java
----------------------------------------------------------------------
diff --git 
a/freemarker-core/src/main/java/org/apache/freemarker/core/ASTDirVisit.java 
b/freemarker-core/src/main/java/org/apache/freemarker/core/ASTDirVisit.java
index 59db5f0..fd49371 100644
--- a/freemarker-core/src/main/java/org/apache/freemarker/core/ASTDirVisit.java
+++ b/freemarker-core/src/main/java/org/apache/freemarker/core/ASTDirVisit.java
@@ -62,7 +62,7 @@ final class ASTDirVisit extends ASTDirective {
                     throw new NonSequenceException(namespaces, nss, env);
                 } else {
                     // Should not occur
-                    throw new _MiscTemplateException(env, "Expecting a 
sequence of namespaces after \"using\"");
+                    throw new TemplateException(env, "Expecting a sequence of 
namespaces after \"using\"");
                 }
             }
         }

http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/22de04e9/freemarker-core/src/main/java/org/apache/freemarker/core/ASTDynamicTopLevelCall.java
----------------------------------------------------------------------
diff --git 
a/freemarker-core/src/main/java/org/apache/freemarker/core/ASTDynamicTopLevelCall.java
 
b/freemarker-core/src/main/java/org/apache/freemarker/core/ASTDynamicTopLevelCall.java
index 7250620..35cd02d 100644
--- 
a/freemarker-core/src/main/java/org/apache/freemarker/core/ASTDynamicTopLevelCall.java
+++ 
b/freemarker-core/src/main/java/org/apache/freemarker/core/ASTDynamicTopLevelCall.java
@@ -114,7 +114,7 @@ class ASTDynamicTopLevelCall extends ASTDirective 
implements CallPlace  {
         }
 
         if (!nestedContentSupported && hasNestedContent()) {
-            throw new _MiscTemplateException(env, "Nested content is not 
supported by this directive.");
+            throw new TemplateException(env, "Nested content is not supported 
by this directive.");
         }
 
         TemplateModel[] execArgs = _CallableUtils.getExecuteArgs(
@@ -125,7 +125,7 @@ class ASTDynamicTopLevelCall extends ASTDirective 
implements CallPlace  {
         } else {
             TemplateModel result = function.execute(execArgs, this, env);
             if (result == null) {
-                throw new _MiscTemplateException(env, "Function has returned 
no value (or null)");
+                throw new TemplateException(env, "Function has returned no 
value (or null)");
             }
             // TODO [FM3] Implement it when we have a such language... it 
should work like `${f()}`.
             throw new BugException("Top-level function call not yet 
implemented");
@@ -288,7 +288,7 @@ class ASTDynamicTopLevelCall extends ASTDirective 
implements CallPlace  {
         int nestedContentParamNamesSize = nestedContentParamNames != null ? 
nestedContentParamNames.size() : 0;
         int nestedContentParamValuesSize = nestedContentArgs != null ? 
nestedContentArgs.length : 0;
         if (nestedContentParamValuesSize != nestedContentParamNamesSize) {
-            throw new _MiscTemplateException(env,
+            throw new TemplateException(env,
                     "The invocation declares ", (nestedContentParamNamesSize 
!= 0 ? nestedContentParamNamesSize : "no"),
                     " nested content parameter(s)",
                     (nestedContentParamNamesSize != 0

http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/22de04e9/freemarker-core/src/main/java/org/apache/freemarker/core/ASTExpArithmetic.java
----------------------------------------------------------------------
diff --git 
a/freemarker-core/src/main/java/org/apache/freemarker/core/ASTExpArithmetic.java
 
b/freemarker-core/src/main/java/org/apache/freemarker/core/ASTExpArithmetic.java
index e05a72c..a15567e 100644
--- 
a/freemarker-core/src/main/java/org/apache/freemarker/core/ASTExpArithmetic.java
+++ 
b/freemarker-core/src/main/java/org/apache/freemarker/core/ASTExpArithmetic.java
@@ -65,10 +65,10 @@ final class ASTExpArithmetic extends ASTExpression {
                 return new SimpleNumber(ae.modulus(lhoNumber, rhoNumber));
             default:
                 if (parent instanceof ASTExpression) {
-                    throw new _MiscTemplateException((ASTExpression) parent,
+                    throw new TemplateException((ASTExpression) parent,
                             "Unknown operation: ", Integer.valueOf(operator));
                 } else {
-                    throw new _MiscTemplateException("Unknown operation: ", 
Integer.valueOf(operator));
+                    throw new TemplateException("Unknown operation: ", 
Integer.valueOf(operator));
                 }
         }
     }

http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/22de04e9/freemarker-core/src/main/java/org/apache/freemarker/core/ASTExpBuiltInVariable.java
----------------------------------------------------------------------
diff --git 
a/freemarker-core/src/main/java/org/apache/freemarker/core/ASTExpBuiltInVariable.java
 
b/freemarker-core/src/main/java/org/apache/freemarker/core/ASTExpBuiltInVariable.java
index d48135e..b32fdb3 100644
--- 
a/freemarker-core/src/main/java/org/apache/freemarker/core/ASTExpBuiltInVariable.java
+++ 
b/freemarker-core/src/main/java/org/apache/freemarker/core/ASTExpBuiltInVariable.java
@@ -196,7 +196,7 @@ final class ASTExpBuiltInVariable extends ASTExpression {
             return new 
SimpleScalar(env.getConfiguration().getIncompatibleImprovements().toString());
         }
         
-        throw new _MiscTemplateException(this,
+        throw new TemplateException(this,
                 "Invalid special variable: ", name);
     }
 

http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/22de04e9/freemarker-core/src/main/java/org/apache/freemarker/core/ASTExpDynamicKeyName.java
----------------------------------------------------------------------
diff --git 
a/freemarker-core/src/main/java/org/apache/freemarker/core/ASTExpDynamicKeyName.java
 
b/freemarker-core/src/main/java/org/apache/freemarker/core/ASTExpDynamicKeyName.java
index c69972f..d8041f7 100644
--- 
a/freemarker-core/src/main/java/org/apache/freemarker/core/ASTExpDynamicKeyName.java
+++ 
b/freemarker-core/src/main/java/org/apache/freemarker/core/ASTExpDynamicKeyName.java
@@ -92,10 +92,10 @@ final class ASTExpDynamicKeyName extends ASTExpression {
                 return new SimpleScalar(s.substring(index, index + 1));
             } catch (IndexOutOfBoundsException e) {
                 if (index < 0) {
-                    throw new _MiscTemplateException("Negative index not 
allowed: ", Integer.valueOf(index));
+                    throw new TemplateException("Negative index not allowed: 
", Integer.valueOf(index));
                 }
                 if (index >= s.length()) {
-                    throw new _MiscTemplateException(
+                    throw new TemplateException(
                             "String index out of range: The index was ", 
Integer.valueOf(index),
                             " (0-based), but the length of the string is only 
", Integer.valueOf(s.length()) , ".");
                 }
@@ -154,7 +154,7 @@ final class ASTExpDynamicKeyName extends ASTExpression {
 
         final int firstIdx = range.getBegining();
         if (firstIdx < 0) {
-            throw new _MiscTemplateException(keyExpression,
+            throw new TemplateException(keyExpression,
                     "Negative range start index (", Integer.valueOf(firstIdx),
                     ") isn't allowed for a range used for slicing.");
         }
@@ -168,7 +168,7 @@ final class ASTExpDynamicKeyName extends ASTExpression {
         // Right-adaptive decreasing ranges has exclusive end -1, so it can't 
help on a  to high firstIndex. 
         // Right-bounded ranges at this point aren't empty, so the right index 
surely can't reach targetSize. 
         if (rightAdaptive && step == 1 ? firstIdx > targetSize : firstIdx >= 
targetSize) {
-            throw new _MiscTemplateException(keyExpression,
+            throw new TemplateException(keyExpression,
                     "Range start index ", Integer.valueOf(firstIdx), " is out 
of bounds, because the sliced ",
                     (targetStr != null ? "string" : "sequence"),
                     " has only ", Integer.valueOf(targetSize), " ", (targetStr 
!= null ? "character(s)" : "element(s)"),
@@ -180,7 +180,7 @@ final class ASTExpDynamicKeyName extends ASTExpression {
             final int lastIdx = firstIdx + (size - 1) * step;
             if (lastIdx < 0) {
                 if (!rightAdaptive) {
-                    throw new _MiscTemplateException(keyExpression,
+                    throw new TemplateException(keyExpression,
                             "Negative range end index (", 
Integer.valueOf(lastIdx),
                             ") isn't allowed for a range used for slicing.");
                 } else {
@@ -188,7 +188,7 @@ final class ASTExpDynamicKeyName extends ASTExpression {
                 }
             } else if (lastIdx >= targetSize) {
                 if (!rightAdaptive) {
-                    throw new _MiscTemplateException(keyExpression,
+                    throw new TemplateException(keyExpression,
                             "Range end index ", Integer.valueOf(lastIdx), " is 
out of bounds, because the sliced ",
                             (targetStr != null ? "string" : "sequence"),
                             " has only ", Integer.valueOf(targetSize), " ", 
(targetStr != null ? "character(s)" : "element(s)"),
@@ -219,7 +219,7 @@ final class ASTExpDynamicKeyName extends ASTExpression {
             final int exclEndIdx;
             if (step < 0 && resultSize > 1) {
                 if (!(range.isAffactedByStringSlicingBug() && resultSize == 
2)) {
-                    throw new _MiscTemplateException(keyExpression,
+                    throw new TemplateException(keyExpression,
                             "Decreasing ranges aren't allowed for slicing 
strings (as it would give reversed text). "
                             + "The index range was: first = ", 
Integer.valueOf(firstIdx),
                             ", last = ", Integer.valueOf(firstIdx + 
(resultSize - 1) * step));

http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/22de04e9/freemarker-core/src/main/java/org/apache/freemarker/core/ASTExpListLiteral.java
----------------------------------------------------------------------
diff --git 
a/freemarker-core/src/main/java/org/apache/freemarker/core/ASTExpListLiteral.java
 
b/freemarker-core/src/main/java/org/apache/freemarker/core/ASTExpListLiteral.java
index 1ddf63c..91d101a 100644
--- 
a/freemarker-core/src/main/java/org/apache/freemarker/core/ASTExpListLiteral.java
+++ 
b/freemarker-core/src/main/java/org/apache/freemarker/core/ASTExpListLiteral.java
@@ -127,7 +127,7 @@ final class ASTExpListLiteral extends ASTExpression {
                     Environment.Namespace ns = env.importLib(s, null);
                     result.add(ns);
                 } catch (IOException ioe) {
-                    throw new _MiscTemplateException(((ASTExpStringLiteral) 
itemExpr),
+                    throw new TemplateException(((ASTExpStringLiteral) 
itemExpr),
                             "Couldn't import library ", new _DelayedJQuote(s), 
": ",
                             new _DelayedGetMessage(ioe));
                 }

http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/22de04e9/freemarker-core/src/main/java/org/apache/freemarker/core/ASTExpVariable.java
----------------------------------------------------------------------
diff --git 
a/freemarker-core/src/main/java/org/apache/freemarker/core/ASTExpVariable.java 
b/freemarker-core/src/main/java/org/apache/freemarker/core/ASTExpVariable.java
index 890563f..1044403 100644
--- 
a/freemarker-core/src/main/java/org/apache/freemarker/core/ASTExpVariable.java
+++ 
b/freemarker-core/src/main/java/org/apache/freemarker/core/ASTExpVariable.java
@@ -39,7 +39,7 @@ final class ASTExpVariable extends ASTExpression {
             return env.getVariable(name);
         } catch (NullPointerException e) {
             if (env == null) {
-                throw new _MiscTemplateException(
+                throw new TemplateException(
                         "Variables are not available (certainly you are in a 
parse-time executed directive). "
                         + "The name of the variable you tried to read: ", 
name);
             } else {

http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/22de04e9/freemarker-core/src/main/java/org/apache/freemarker/core/BuiltInForNestedContentParameter.java
----------------------------------------------------------------------
diff --git 
a/freemarker-core/src/main/java/org/apache/freemarker/core/BuiltInForNestedContentParameter.java
 
b/freemarker-core/src/main/java/org/apache/freemarker/core/BuiltInForNestedContentParameter.java
index 9847352..d35c2f5 100644
--- 
a/freemarker-core/src/main/java/org/apache/freemarker/core/BuiltInForNestedContentParameter.java
+++ 
b/freemarker-core/src/main/java/org/apache/freemarker/core/BuiltInForNestedContentParameter.java
@@ -35,7 +35,7 @@ abstract class BuiltInForNestedContentParameter extends 
SpecialBuiltIn {
         IterationContext iterCtx = 
ASTDirList.findEnclosingIterationContext(env, nestedContentParamName);
         if (iterCtx == null) {
             // The parser should prevent this situation
-            throw new _MiscTemplateException(
+            throw new TemplateException(
                     this, env,
                     "There's no iteration in context that uses the nested 
content parameter ",
                     new _DelayedJQuote( nestedContentParamName), ".");

http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/22de04e9/freemarker-core/src/main/java/org/apache/freemarker/core/BuiltInsForDates.java
----------------------------------------------------------------------
diff --git 
a/freemarker-core/src/main/java/org/apache/freemarker/core/BuiltInsForDates.java
 
b/freemarker-core/src/main/java/org/apache/freemarker/core/BuiltInsForDates.java
index 829c5fa..7d7a57c 100644
--- 
a/freemarker-core/src/main/java/org/apache/freemarker/core/BuiltInsForDates.java
+++ 
b/freemarker-core/src/main/java/org/apache/freemarker/core/BuiltInsForDates.java
@@ -188,7 +188,7 @@ class BuiltInsForDates {
         void checkDateTypeNotUnknown(int dateType)
         throws TemplateException {
             if (dateType == TemplateDateModel.UNKNOWN) {
-                throw new _MiscTemplateException(new _ErrorDescriptionBuilder(
+                throw new TemplateException(new _ErrorDescriptionBuilder(
                             "The value of the following has unknown date type, 
but ?", key,
                             " needs a value where it's known if it's a date 
(no time part), time, or date-time value:"                        
                         
).blame(target).tip(MessageUtils.UNKNOWN_DATE_TYPE_ERROR_TIP));

http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/22de04e9/freemarker-core/src/main/java/org/apache/freemarker/core/BuiltInsForMultipleTypes.java
----------------------------------------------------------------------
diff --git 
a/freemarker-core/src/main/java/org/apache/freemarker/core/BuiltInsForMultipleTypes.java
 
b/freemarker-core/src/main/java/org/apache/freemarker/core/BuiltInsForMultipleTypes.java
index 6632654..5d6dccc 100644
--- 
a/freemarker-core/src/main/java/org/apache/freemarker/core/BuiltInsForMultipleTypes.java
+++ 
b/freemarker-core/src/main/java/org/apache/freemarker/core/BuiltInsForMultipleTypes.java
@@ -214,7 +214,7 @@ class BuiltInsForMultipleTypes {
                 if (dtype == TemplateDateModel.UNKNOWN || dtype == 
TemplateDateModel.DATE_TIME) {
                     return new SimpleDate(dmodel.getAsDate(), dateType);
                 }
-                throw new _MiscTemplateException(this,
+                throw new TemplateException(this,
                             "Cannot convert ", 
TemplateDateModel.TYPE_NAMES.get(dtype),
                             " to ", 
TemplateDateModel.TYPE_NAMES.get(dateType));
             }
@@ -230,7 +230,7 @@ class BuiltInsForMultipleTypes {
         @Override
         TemplateModel _eval(Environment env) throws TemplateException {
             if (!env.getAPIBuiltinEnabled()) {
-                throw new _MiscTemplateException(this,
+                throw new TemplateException(this,
                         "Can't use ?api, because the \"", 
MutableProcessingConfiguration.API_BUILTIN_ENABLED_KEY,
                         "\" configuration setting is false. Think twice before 
you set it to true though. Especially, "
                         + "it shouldn't abused for modifying Map-s and 
Collection-s.");

http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/22de04e9/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 b7a0e93..e9dc852 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
@@ -191,7 +191,7 @@ class BuiltInsForStringsBasic {
                     }
                 } else {
                     if (flagsArg != null) {
-                        throw new _MiscTemplateException(
+                        throw new TemplateException(
                                 "The 2nd parameter must be non-null when the 
3rd parameter is non-null");
                     }
                     startsWithPrefix = s.startsWith(checkedPrefix);

http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/22de04e9/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 c90f15d..ab1dbb3 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
@@ -54,7 +54,7 @@ class BuiltInsForStringsMisc {
             } else if 
(s.equals(env.getTemplateBooleanFormat().getFalseStringValue())) {
                 b = false;
             } else {
-                throw new _MiscTemplateException(this, env,
+                throw new TemplateException(this, env,
                         "Can't convert this string to boolean: ", new 
_DelayedJQuote(s));
             }
             return b ? TemplateBooleanModel.TRUE : TemplateBooleanModel.FALSE;
@@ -96,7 +96,7 @@ class BuiltInsForStringsMisc {
                     throw e.toParseException(parentTemplate);
                 }
             } catch (ParseException e) {
-                throw new _MiscTemplateException(this, env,
+                throw new TemplateException(this, env,
                         "Failed to \"?", key, "\" string with this error:\n\n",
                         MessageUtils.EMBEDDED_MESSAGE_BEGIN,
                         new _DelayedGetMessage(e),
@@ -106,7 +106,7 @@ class BuiltInsForStringsMisc {
             try {
                 return exp.eval(env);
             } catch (TemplateException e) {
-                throw new _MiscTemplateException(this, env,
+                throw new TemplateException(this, env,
                         "Failed to \"?", key, "\" string with this error:\n\n",
                         MessageUtils.EMBEDDED_MESSAGE_BEGIN,
                         new _DelayedGetMessageWithoutStackTop(e),
@@ -179,7 +179,7 @@ class BuiltInsForStringsMisc {
                         outputFormat, autoEscapingPolicy,
                         null, null);
             } catch (IOException e) {
-                throw new _MiscTemplateException(this, e, env,
+                throw new TemplateException(this, e, env,
                         "Template parsing with \"?", key, "\" has failed with 
this error:\n\n",
                         MessageUtils.EMBEDDED_MESSAGE_BEGIN,
                         new _DelayedGetMessage(e),
@@ -262,11 +262,11 @@ class BuiltInsForStringsMisc {
                 this.env = env;
                 cl = env.getNewBuiltinClassResolver().resolve(classname, env, 
template);
                 if (!TemplateModel.class.isAssignableFrom(cl)) {
-                    throw new _MiscTemplateException(newBI.this, env,
+                    throw new TemplateException(newBI.this, env,
                             "Class ", cl.getName(), " does not implement 
org.apache.freemarker.core.TemplateModel");
                 }
                 if (BeanModel.class.isAssignableFrom(cl)) {
-                    throw new _MiscTemplateException(newBI.this, env,
+                    throw new TemplateException(newBI.this, env,
                             "Bean Models cannot be instantiated using the ?", 
key, " built-in");
                 }
             }

http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/22de04e9/freemarker-core/src/main/java/org/apache/freemarker/core/BuiltInsWithParseTimeParameters.java
----------------------------------------------------------------------
diff --git 
a/freemarker-core/src/main/java/org/apache/freemarker/core/BuiltInsWithParseTimeParameters.java
 
b/freemarker-core/src/main/java/org/apache/freemarker/core/BuiltInsWithParseTimeParameters.java
index d88c2d9..0aa7338 100644
--- 
a/freemarker-core/src/main/java/org/apache/freemarker/core/BuiltInsWithParseTimeParameters.java
+++ 
b/freemarker-core/src/main/java/org/apache/freemarker/core/BuiltInsWithParseTimeParameters.java
@@ -144,7 +144,7 @@ final class BuiltInsWithParseTimeParameters {
             }
             
             if (paramCnt % 2 == 0) {
-                throw new _MiscTemplateException(target,
+                throw new TemplateException(target,
                         "The value before ?", key, "(case1, value1, case2, 
value2, ...) didn't match any of the "
                         + "case parameters, and there was no default value 
parameter (an additional last parameter) "
                         + "eithter. ");

http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/22de04e9/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 a035da5..4ce70a2 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
@@ -504,7 +504,7 @@ public final class Environment extends 
MutableProcessingConfiguration<Environmen
 
     String getCurrentRecoveredErrorMessage() throws TemplateException {
         if (recoveredErrorStack.isEmpty()) {
-            throw new _MiscTemplateException(this, ".error is not available 
outside of a #recover block");
+            throw new TemplateException(this, ".error is not available outside 
of a #recover block");
         }
         return ((Throwable) recoveredErrorStack.get(recoveredErrorStack.size() 
- 1)).getMessage();
     }
@@ -601,11 +601,11 @@ public final class Environment extends 
MutableProcessingConfiguration<Environmen
                     else if (!nodeType.equals("pi")
                             && !nodeType.equals("comment")
                             && !nodeType.equals("document_type")) {
-                        throw new _MiscTemplateException(
+                        throw new TemplateException(
                                 this, noNodeHandlerDefinedDescription(node, 
node.getNodeNamespace(), nodeType));
                     }
                 } else {
-                    throw new _MiscTemplateException(
+                    throw new TemplateException(
                             this, noNodeHandlerDefinedDescription(node, 
node.getNodeNamespace(), "default"));
                 }
             }
@@ -1028,7 +1028,7 @@ public final class Environment extends 
MutableProcessingConfiguration<Environmen
                 if (fallbackToTrueFalse) {
                     return TemplateBooleanFormat.C_TRUE;
                 } else {
-                    throw new 
_MiscTemplateException(getNullBooleanFormatErrorDescription());
+                    throw new 
TemplateException(getNullBooleanFormatErrorDescription());
                 }
             } else {
                 return s;
@@ -1039,7 +1039,7 @@ public final class Environment extends 
MutableProcessingConfiguration<Environmen
                 if (fallbackToTrueFalse) {
                     return TemplateBooleanFormat.C_FALSE;
                 } else {
-                    throw new 
_MiscTemplateException(getNullBooleanFormatErrorDescription());
+                    throw new 
TemplateException(getNullBooleanFormatErrorDescription());
                 }
             } else {
                 return s;
@@ -1180,7 +1180,7 @@ public final class Environment extends 
MutableProcessingConfiguration<Environmen
                     new _DelayedJQuote(getNumberFormat()), ": ", 
e.getMessage())
                     .blame(exp); 
             throw useTempModelExc
-                    ? new _TemplateModelException(e, this, desc) : new 
_MiscTemplateException(e, this, desc);
+                    ? new _TemplateModelException(e, this, desc) : new 
TemplateException(e, this, desc);
         }
         return format;
     }
@@ -1202,7 +1202,7 @@ public final class Environment extends 
MutableProcessingConfiguration<Environmen
                     " number format string: ", e.getMessage())
                     .blame(exp);
             throw useTempModelExc
-                    ? new _TemplateModelException(e, this, desc) : new 
_MiscTemplateException(e, this, desc);
+                    ? new _TemplateModelException(e, this, desc) : new 
TemplateException(e, this, desc);
         }
         return format;
     }
@@ -1610,7 +1610,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 
_MiscTemplateException(e, desc);
+            throw useTempModelExc ? new _TemplateModelException(e, desc) : new 
TemplateException(e, desc);
         }
     }
 
@@ -1633,7 +1633,7 @@ public final class Environment extends 
MutableProcessingConfiguration<Environmen
                     new _DelayedJQuote(formatString), ". Reason given: ",
                     e.getMessage())
                     .blame(blamedFormatterExp);
-            throw useTempModelExc ? new _TemplateModelException(e, desc) : new 
_MiscTemplateException(e, desc);
+            throw useTempModelExc ? new _TemplateModelException(e, desc) : new 
TemplateException(e, desc);
         }
     }
 
@@ -2313,7 +2313,7 @@ public final class Environment extends 
MutableProcessingConfiguration<Environmen
     TemplateDirectiveModel getNodeProcessor(TemplateNodeModel node) throws 
TemplateException {
         String nodeName = node.getNodeName();
         if (nodeName == null) {
-            throw new _MiscTemplateException(this, "Node name was null.");
+            throw new TemplateException(this, "Node name was null.");
         }
         TemplateDirectiveModel result = getNodeProcessor(nodeName, 
node.getNodeNamespace(), 0);
 
@@ -2344,7 +2344,7 @@ public final class Environment extends 
MutableProcessingConfiguration<Environmen
             try {
                 ns = (Namespace) nodeNamespaces.get(i);
             } catch (ClassCastException cce) {
-                throw new _MiscTemplateException(this,
+                throw new TemplateException(this,
                         "A \"using\" clause should contain a sequence of 
namespaces or strings that indicate the "
                                 + "location of importable macro libraries.");
             }
@@ -2989,7 +2989,7 @@ public final class Environment extends 
MutableProcessingConfiguration<Environmen
                     } else {
                         // TODO [FM3] Had to give different messages depending 
on if the argument was omitted, or if
                         // it was null, but this will be fixed with the null 
related refactoring.
-                        throw new _MiscTemplateException(Environment.this,
+                        throw new TemplateException(Environment.this,
                                 new _ErrorDescriptionBuilder(
                                         "When calling macro ", new 
_DelayedJQuote(callableDefinition.getName()),
                                         ", required parameter ", new 
_DelayedJQuote(paramDef.getName()),

http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/22de04e9/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 3ce73b8..971f660 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
@@ -276,7 +276,7 @@ class MessageUtils {
     }
     
     static TemplateException newInstantiatingClassNotAllowedException(String 
className, Environment env) {
-        return new _MiscTemplateException(env,
+        return new TemplateException(env,
                 "Instantiating ", className, " is not allowed in the template 
for security reasons.");
     }
     
@@ -296,7 +296,7 @@ class MessageUtils {
                 .blame(dataSrcExp); 
         return useTempModelExc
                 ? new _TemplateModelException(e, null, desc)
-                : new _MiscTemplateException(e, null, desc);
+                : new TemplateException(e, null, desc);
     }
     
     static TemplateException newCantFormatNumberException(TemplateNumberFormat 
format, ASTExpression dataSrcExp,
@@ -307,7 +307,7 @@ class MessageUtils {
                 .blame(dataSrcExp); 
         return useTempModelExc
                 ? new _TemplateModelException(e, null, desc)
-                : new _MiscTemplateException(e, null, desc);
+                : new TemplateException(e, null, desc);
     }
     
     /**

http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/22de04e9/freemarker-core/src/main/java/org/apache/freemarker/core/TemplateClassResolver.java
----------------------------------------------------------------------
diff --git 
a/freemarker-core/src/main/java/org/apache/freemarker/core/TemplateClassResolver.java
 
b/freemarker-core/src/main/java/org/apache/freemarker/core/TemplateClassResolver.java
index 0e04b4f..b299d0f 100644
--- 
a/freemarker-core/src/main/java/org/apache/freemarker/core/TemplateClassResolver.java
+++ 
b/freemarker-core/src/main/java/org/apache/freemarker/core/TemplateClassResolver.java
@@ -44,7 +44,7 @@ public interface TemplateClassResolver {
             try {
                 return _ClassUtils.forName(className);
             } catch (ClassNotFoundException e) {
-                throw new _MiscTemplateException(e, env);
+                throw new TemplateException(e, env);
             }
         }
         

http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/22de04e9/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 e7f387f..06cb20f 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
@@ -102,27 +102,20 @@ public class TemplateException extends Exception {
     }
     
     /**
-     * The same as {@link #TemplateException(String, Throwable, Environment)}; 
it's exists only for binary
-     * backward-compatibility.
-     */
-    public TemplateException(String description, Exception cause, Environment 
env) {
-        this(description, cause, env, null, null);
-    }
-
-    /**
      * Constructs a TemplateException 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
+     * @param env Can be null{@code null}, in which case {@link 
Environment#getCurrentEnvironment()} is used.
      */
     public TemplateException(String description, Throwable cause, Environment 
env) {
         this(description, cause, env, null, null);
     }
-    
+
     /**
-     * Don't use this; this is to be used internally by FreeMarker. No 
backward compatibility guarantees.
+     * Do not use; To be used internally by FreeMarker. No backward 
compatibility guarantees.
      * 
      * @param blamedExpr Maybe {@code null}. The FTL stack in the {@link 
Environment} only specifies the error location
      *          with "template element" granularity, and this can be used to 
point to the expression inside the
@@ -132,7 +125,111 @@ public class TemplateException extends Exception {
             _ErrorDescriptionBuilder descriptionBuilder) {
         this(null, cause, env, blamedExpr, descriptionBuilder);
     }
-    
+
+    // 
-----------------------------------------------------------------------------------------------------------------
+    // BEGIN FM2 TemplateException constructors
+    // 
-----------------------------------------------------------------------------------------------------------------
+    // TODO [FM3] This was mindlessly copy-pasted. Make order here...
+
+    // 
-----------------------------------------------------------------------------------------------------------------
+    // Permutation group:
+
+    public TemplateException(String description) {
+        this(description, null);
+    }
+
+    TemplateException(Environment env, String description) {
+        this(description, env);
+    }
+
+    // 
-----------------------------------------------------------------------------------------------------------------
+    // Permutation group:
+
+    TemplateException(Throwable cause, String description) {
+        this(cause, null, description);
+    }
+
+    TemplateException(Throwable cause) {
+        this(cause, null, (String) null);
+    }
+
+    TemplateException(Throwable cause, Environment env, String description) {
+        this(description, cause, env);
+    }
+
+    // 
-----------------------------------------------------------------------------------------------------------------
+    // Permutation group:
+
+    TemplateException(_ErrorDescriptionBuilder description) {
+        this(null, description);
+    }
+
+    TemplateException(Environment env, _ErrorDescriptionBuilder description) {
+        this(null, env, description);
+    }
+
+    TemplateException(Throwable cause, Environment env, 
_ErrorDescriptionBuilder description) {
+        this(cause, env, null, description);
+    }
+
+    // 
-----------------------------------------------------------------------------------------------------------------
+    // Permutation group:
+
+    /**
+     * @param descriptionParts
+     *         Array of objects that will be rendered into {@link String} on 
demand (if and when the exception message
+     *         is ever needed).
+     */
+    public TemplateException(Object... descriptionParts) {
+        this((Environment) null, descriptionParts);
+    }
+
+    public TemplateException(Environment env, Object... descriptionParts) {
+        this((Throwable) null, env, descriptionParts);
+    }
+
+    public TemplateException(Throwable cause, Object... descriptionParts) {
+        this(cause, null, descriptionParts);
+    }
+
+    public TemplateException(Throwable cause, Environment env, Object... 
descriptionParts) {
+        this(cause, env, null, new _ErrorDescriptionBuilder(descriptionParts));
+    }
+
+    // 
-----------------------------------------------------------------------------------------------------------------
+    // Permutation group:
+
+    TemplateException(ASTExpression blamed, Object... descriptionParts) {
+        this(blamed, null, descriptionParts);
+    }
+
+    TemplateException(ASTExpression blamed, Environment env, Object... 
descriptionParts) {
+        this(blamed, null, env, descriptionParts);
+    }
+
+    TemplateException(ASTExpression blamed, Throwable cause, Environment env, 
Object... descriptionParts) {
+        this(cause, env, blamed, new 
_ErrorDescriptionBuilder(descriptionParts).blame(blamed));
+    }
+
+    // 
-----------------------------------------------------------------------------------------------------------------
+    // Permutation group:
+
+    TemplateException(ASTExpression blamed, String description) {
+        this(blamed, null, description);
+    }
+
+    TemplateException(ASTExpression blamed, Environment env, String 
description) {
+        this(blamed, null, env, description);
+    }
+
+    TemplateException(ASTExpression blamed, Throwable cause, Environment env, 
String description) {
+        this(cause, env, blamed, new 
_ErrorDescriptionBuilder(description).blame(blamed));
+    }
+
+    // 
-----------------------------------------------------------------------------------------------------------------
+    // END FM2 TemplateException constructors
+    // 
-----------------------------------------------------------------------------------------------------------------
+
     private TemplateException(
             String renderedDescription,
             Throwable cause,            

http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/22de04e9/freemarker-core/src/main/java/org/apache/freemarker/core/_CallableUtils.java
----------------------------------------------------------------------
diff --git 
a/freemarker-core/src/main/java/org/apache/freemarker/core/_CallableUtils.java 
b/freemarker-core/src/main/java/org/apache/freemarker/core/_CallableUtils.java
index fb2143a..ecef475 100644
--- 
a/freemarker-core/src/main/java/org/apache/freemarker/core/_CallableUtils.java
+++ 
b/freemarker-core/src/main/java/org/apache/freemarker/core/_CallableUtils.java
@@ -119,7 +119,7 @@ public final class _CallableUtils {
             if (optional) {
                 return null;
             }
-            throw new _MiscTemplateException(
+            throw new TemplateException(
                     "The ", argName != null ? new _DelayedJQuote(argName) : 
new _DelayedOrdinal(argIndex + 1),
                     " argument can't be null.");
         }
@@ -167,7 +167,7 @@ public final class _CallableUtils {
             if (optional) {
                 return null;
             }
-            throw new _MiscTemplateException(
+            throw new TemplateException(
                     "The ", argName != null ? new _DelayedJQuote(argName) : 
new _DelayedOrdinal(argIndex + 1),
                     " argument can't be null.");
         }
@@ -188,7 +188,7 @@ public final class _CallableUtils {
             NamedArgument[] namedArgs, TemplateCallableModel callableValue, 
Environment env)
             throws TemplateException {
         if (namedArgs != null) {
-            throw new _MiscTemplateException(env, 
getNamedArgumentsNotSupportedMessage(callableValue, namedArgs[0]));
+            throw new TemplateException(env, 
getNamedArgumentsNotSupportedMessage(callableValue, namedArgs[0]));
         }
 
         TemplateModel[] execArgs;
@@ -264,7 +264,7 @@ public final class _CallableUtils {
                         + " have tried now) when the macro has defined that 
parameter to be a positional parameter. "
                         + "See in the documentation how, and when that's a 
good practice.");
             }
-            throw new _MiscTemplateException(env,
+            throw new TemplateException(env,
                     errorDesc
             );
         }
@@ -282,7 +282,7 @@ public final class _CallableUtils {
                         if (namedVarargsArgumentIndex == -1) {
                             checkSupportsAnyParameters(callableValue, 
argsLayout, env);
                             Collection<String> validNames = 
predefNamedArgsMap.getKeys();
-                            throw new _MiscTemplateException(env,
+                            throw new TemplateException(env,
                                     validNames == null || validNames.isEmpty()
                                             ? 
getNamedArgumentsNotSupportedMessage(callableValue, namedArg)
                                             : new Object[] {
@@ -324,7 +324,7 @@ public final class _CallableUtils {
             TemplateCallableModel callableValue, ArgumentArrayLayout 
argsLayout, Environment env)
             throws TemplateException {
         if (argsLayout.getTotalLength() == 0) {
-            throw new _MiscTemplateException(env,
+            throw new TemplateException(env,
                     "The called ", 
TemplateLanguageUtils.getCallableTypeName(callableValue), " doesn't support any 
parameters.");
         }
     }

http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/22de04e9/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 199a88c..2c29856 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
@@ -193,7 +193,7 @@ public class _EvalUtils {
                 if (leftExp != null) {
                     throw InvalidReferenceException.getInstance(leftExp, env);
                 } else {
-                    throw new _MiscTemplateException(defaultBlamed, env, 
+                    throw new TemplateException(defaultBlamed, env,
                                 "The left operand of the comparison was 
undefined or null.");
                 }
             }
@@ -206,7 +206,7 @@ public class _EvalUtils {
                 if (rightExp != null) {
                     throw InvalidReferenceException.getInstance(rightExp, env);
                 } else {
-                    throw new _MiscTemplateException(defaultBlamed, env,
+                    throw new TemplateException(defaultBlamed, env,
                                 "The right operand of the comparison was 
undefined or null.");
                 }
             }
@@ -225,7 +225,7 @@ public class _EvalUtils {
             try {
                 cmpResult = ae.compareNumbers(leftNum, rightNum);
             } catch (RuntimeException e) {
-                throw new _MiscTemplateException(defaultBlamed, e, env,
+                throw new TemplateException(defaultBlamed, e, env,
                         "Unexpected error while comparing two numbers: ", e);
             }
         } else if (leftValue instanceof TemplateDateModel && rightValue 
instanceof TemplateDateModel) {
@@ -246,12 +246,12 @@ public class _EvalUtils {
                     sideExp = rightExp;
                 }
                 
-                throw new _MiscTemplateException(sideExp != null ? sideExp : 
defaultBlamed, env,
+                throw new TemplateException(sideExp != null ? sideExp : 
defaultBlamed, env,
                         "The ", sideName, " ", 
VALUE_OF_THE_COMPARISON_IS_UNKNOWN_DATE_LIKE);
             }
             
             if (leftDateType != rightDateType) {
-                throw new _MiscTemplateException(defaultBlamed, env,
+                throw new TemplateException(defaultBlamed, env,
                         "Can't compare dates of different types. Left date 
type is ",
                         TemplateDateModel.TYPE_NAMES.get(leftDateType), ", 
right date type is ",
                         TemplateDateModel.TYPE_NAMES.get(rightDateType), ".");
@@ -262,7 +262,7 @@ public class _EvalUtils {
             cmpResult = leftDate.compareTo(rightDate);
         } else if (leftValue instanceof TemplateScalarModel && rightValue 
instanceof TemplateScalarModel) {
             if (operator != CMP_OP_EQUALS && operator != CMP_OP_NOT_EQUALS) {
-                throw new _MiscTemplateException(defaultBlamed, env,
+                throw new TemplateException(defaultBlamed, env,
                         "Can't use operator \"", cmpOpToString(operator, 
operatorString), "\" on string values.");
             }
             String leftString = _EvalUtils.modelToString((TemplateScalarModel) 
leftValue, leftExp, env);
@@ -271,7 +271,7 @@ public class _EvalUtils {
             cmpResult = env.getCollator().compare(leftString, rightString);
         } else if (leftValue instanceof TemplateBooleanModel && rightValue 
instanceof TemplateBooleanModel) {
             if (operator != CMP_OP_EQUALS && operator != CMP_OP_NOT_EQUALS) {
-                throw new _MiscTemplateException(defaultBlamed, env,
+                throw new TemplateException(defaultBlamed, env,
                         "Can't use operator \"", cmpOpToString(operator, 
operatorString), "\" on boolean values.");
             }
             boolean leftBool = ((TemplateBooleanModel) 
leftValue).getAsBoolean();
@@ -286,7 +286,7 @@ public class _EvalUtils {
                 }
                 // Falls through
             }
-            throw new _MiscTemplateException(defaultBlamed, env,
+            throw new TemplateException(defaultBlamed, env,
                     "Can't compare values of these types. ",
                     "Allowed comparisons are between two numbers, two strings, 
two dates, or two booleans.\n",
                     "Left hand operand ",
@@ -523,9 +523,9 @@ public class _EvalUtils {
                         " format, while the right hand operand is in ", new 
_DelayedToString(rightOF),
                         ". Conversion to common format wasn't possible." };
                 if (parent instanceof ASTExpression) {
-                    throw new _MiscTemplateException((ASTExpression) parent, 
message);
+                    throw new TemplateException((ASTExpression) parent, 
message);
                 } else {
-                    throw new _MiscTemplateException(message);
+                    throw new TemplateException(message);
                 }
             }
         } else {

http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/22de04e9/freemarker-core/src/main/java/org/apache/freemarker/core/_MiscTemplateException.java
----------------------------------------------------------------------
diff --git 
a/freemarker-core/src/main/java/org/apache/freemarker/core/_MiscTemplateException.java
 
b/freemarker-core/src/main/java/org/apache/freemarker/core/_MiscTemplateException.java
deleted file mode 100644
index 1c8abfe..0000000
--- 
a/freemarker-core/src/main/java/org/apache/freemarker/core/_MiscTemplateException.java
+++ /dev/null
@@ -1,124 +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;
-
-/**
- * For internal use only; don't depend on this, there's no backward 
compatibility guarantee at all!
- * {@link TemplateException}-s that don't fit into any category that warrant 
its own class. In fact, this was added
- * because the API of {@link TemplateException} is too simple for the purposes 
of the core, but it can't be
- * extended without breaking backward compatibility and exposing internals.  
- */
-public class _MiscTemplateException extends TemplateException {
-
-    // 
-----------------------------------------------------------------------------------------------------------------
-    // Permutation group:
-    
-    public _MiscTemplateException(String description) {
-        super(description, null);
-    }
-
-    public _MiscTemplateException(Environment env, String description) {
-        super(description, env);
-    }
-    
-    // 
-----------------------------------------------------------------------------------------------------------------
-    // Permutation group:
-
-    public _MiscTemplateException(Throwable cause, String description) {
-        this(cause, null, description);
-    }
-
-    public _MiscTemplateException(Throwable cause, Environment env) {
-        this(cause, env, (String) null);
-    }
-
-    public _MiscTemplateException(Throwable cause) {
-        this(cause, null, (String) null);
-    }
-    
-    public _MiscTemplateException(Throwable cause, Environment env, String 
description) {
-        super(description, cause, env);
-    }
-
-    // 
-----------------------------------------------------------------------------------------------------------------
-    // Permutation group:
-    
-    public _MiscTemplateException(_ErrorDescriptionBuilder description) {
-        this(null, description);
-    }
-
-    public _MiscTemplateException(Environment env, _ErrorDescriptionBuilder 
description) {
-        this(null, env, description);
-    }
-
-    public _MiscTemplateException(Throwable cause, Environment env, 
_ErrorDescriptionBuilder description) {
-        super(cause, env, null, description);
-    }
-
-    // 
-----------------------------------------------------------------------------------------------------------------
-    // Permutation group:
-    
-    public _MiscTemplateException(Object... descriptionParts) {
-        this((Environment) null, descriptionParts);
-    }
-
-    public _MiscTemplateException(Environment env, Object... descriptionParts) 
{
-        this((Throwable) null, env, descriptionParts);
-    }
-
-    public _MiscTemplateException(Throwable cause, Object... descriptionParts) 
{
-        this(cause, null, descriptionParts);
-    }
-
-    public _MiscTemplateException(Throwable cause, Environment env, Object... 
descriptionParts) {
-        super(cause, env, null, new 
_ErrorDescriptionBuilder(descriptionParts));
-    }
-
-    // 
-----------------------------------------------------------------------------------------------------------------
-    // Permutation group:
-    
-    public _MiscTemplateException(ASTExpression blamed, Object... 
descriptionParts) {
-        this(blamed, null, descriptionParts);
-    }
-
-    public _MiscTemplateException(ASTExpression blamed, Environment env, 
Object... descriptionParts) {
-        this(blamed, null, env, descriptionParts);
-    }
-
-    public _MiscTemplateException(ASTExpression blamed, Throwable cause, 
Environment env, Object... descriptionParts) {
-        super(cause, env, blamed, new 
_ErrorDescriptionBuilder(descriptionParts).blame(blamed));
-    }
-
-    // 
-----------------------------------------------------------------------------------------------------------------
-    // Permutation group:
-    
-    public _MiscTemplateException(ASTExpression blamed, String description) {
-        this(blamed, null, description);
-    }
-
-    public _MiscTemplateException(ASTExpression blamed, Environment env, 
String description) {
-        this(blamed, null, env, description);
-    }
-
-    public _MiscTemplateException(ASTExpression blamed, Throwable cause, 
Environment env, String description) {
-        super(cause, env, blamed, new 
_ErrorDescriptionBuilder(description).blame(blamed));
-    }
-    
-}

http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/22de04e9/freemarker-core/src/main/java/org/apache/freemarker/core/arithmetic/impl/ConservativeArithmeticEngine.java
----------------------------------------------------------------------
diff --git 
a/freemarker-core/src/main/java/org/apache/freemarker/core/arithmetic/impl/ConservativeArithmeticEngine.java
 
b/freemarker-core/src/main/java/org/apache/freemarker/core/arithmetic/impl/ConservativeArithmeticEngine.java
index 16f58a2..e39cae3 100644
--- 
a/freemarker-core/src/main/java/org/apache/freemarker/core/arithmetic/impl/ConservativeArithmeticEngine.java
+++ 
b/freemarker-core/src/main/java/org/apache/freemarker/core/arithmetic/impl/ConservativeArithmeticEngine.java
@@ -24,7 +24,6 @@ import java.util.HashMap;
 import java.util.Map;
 
 import org.apache.freemarker.core.TemplateException;
-import org.apache.freemarker.core._MiscTemplateException;
 import org.apache.freemarker.core.arithmetic.ArithmeticEngine;
 import org.apache.freemarker.core.util.BugException;
 import org.apache.freemarker.core.util._NumberUtils;
@@ -309,7 +308,7 @@ public class ConservativeArithmeticEngine extends 
ArithmeticEngine {
                 return n1.mod(n2);
             }
             case BIG_DECIMAL: {
-                throw new _MiscTemplateException("Can't calculate remainder on 
BigDecimals");
+                throw new TemplateException("Can't calculate remainder on 
BigDecimals");
             }
         }
         // Make the compiler happy. getCommonClassCode() is guaranteed to
@@ -342,9 +341,9 @@ public class ConservativeArithmeticEngine extends 
ArithmeticEngine {
             return ((Integer) classCodes.get(num.getClass())).intValue();
         } catch (NullPointerException e) {
             if (num == null) {
-                throw new _MiscTemplateException("The Number object was 
null.");
+                throw new TemplateException("The Number object was null.");
             } else {
-                throw new _MiscTemplateException("Unknown number type ", 
num.getClass().getName());
+                throw new TemplateException("Unknown number type ", 
num.getClass().getName());
             }
         }
     }

http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/22de04e9/freemarker-core/src/main/java/org/apache/freemarker/core/util/OptInTemplateClassResolver.java
----------------------------------------------------------------------
diff --git 
a/freemarker-core/src/main/java/org/apache/freemarker/core/util/OptInTemplateClassResolver.java
 
b/freemarker-core/src/main/java/org/apache/freemarker/core/util/OptInTemplateClassResolver.java
index 558e09d..b2614d7 100644
--- 
a/freemarker-core/src/main/java/org/apache/freemarker/core/util/OptInTemplateClassResolver.java
+++ 
b/freemarker-core/src/main/java/org/apache/freemarker/core/util/OptInTemplateClassResolver.java
@@ -26,12 +26,11 @@ import java.util.Iterator;
 import java.util.List;
 import java.util.Set;
 
-import org.apache.freemarker.core.MutableProcessingConfiguration;
 import org.apache.freemarker.core.Environment;
+import org.apache.freemarker.core.MutableProcessingConfiguration;
 import org.apache.freemarker.core.Template;
 import org.apache.freemarker.core.TemplateClassResolver;
 import org.apache.freemarker.core.TemplateException;
-import org.apache.freemarker.core._MiscTemplateException;
 
 /**
  * A {@link TemplateClassResolver} that resolves only the classes whose name
@@ -101,7 +100,7 @@ public class OptInTemplateClassResolver implements 
TemplateClassResolver {
             return TemplateClassResolver.UNRESTRICTED.resolve(className, env, 
template);
         } else {
             if (!allowedClasses.contains(className)) {
-                throw new _MiscTemplateException(env,
+                throw new TemplateException(env,
                         "Instantiating ", className, " is not allowed in the 
template for security reasons. (If you "
                         + "run into this problem when using ?new in a 
template, you may want to check the \"",
                         
MutableProcessingConfiguration.NEW_BUILTIN_CLASS_RESOLVER_KEY,
@@ -110,7 +109,7 @@ public class OptInTemplateClassResolver implements 
TemplateClassResolver {
                 try {
                     return _ClassUtils.forName(className);
                 } catch (ClassNotFoundException e) {
-                    throw new _MiscTemplateException(e, env);
+                    throw new TemplateException(e, env);
                 }
             }
         }

http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/22de04e9/freemarker-servlet/src/main/java/org/apache/freemarker/servlet/IncludePage.java
----------------------------------------------------------------------
diff --git 
a/freemarker-servlet/src/main/java/org/apache/freemarker/servlet/IncludePage.java
 
b/freemarker-servlet/src/main/java/org/apache/freemarker/servlet/IncludePage.java
index 0f2a061..a1504ff 100644
--- 
a/freemarker-servlet/src/main/java/org/apache/freemarker/servlet/IncludePage.java
+++ 
b/freemarker-servlet/src/main/java/org/apache/freemarker/servlet/IncludePage.java
@@ -39,7 +39,7 @@ import javax.servlet.http.HttpServletResponseWrapper;
 import org.apache.freemarker.core.Environment;
 import org.apache.freemarker.core.TemplateException;
 import org.apache.freemarker.core._DelayedFTLTypeDescription;
-import org.apache.freemarker.core._MiscTemplateException;
+import org.apache.freemarker.core.TemplateException;
 import org.apache.freemarker.core.model.ArgumentArrayLayout;
 import org.apache.freemarker.core.CallPlace;
 import org.apache.freemarker.core.model.TemplateBooleanModel;
@@ -95,16 +95,16 @@ public class IncludePage implements TemplateDirectiveModel {
         // Determine the path
         final TemplateModel path = args[PATH_PARAM_IDX];
         if (path == null) {
-            throw new _MiscTemplateException(env, "Missing required parameter 
\"path\"");
+            throw new TemplateException(env, "Missing required parameter 
\"path\"");
         }
         if (!(path instanceof TemplateScalarModel)) {
-            throw new _MiscTemplateException(env,
+            throw new TemplateException(env,
                     "Expected a scalar model. \"", PATH_PARAM_NAME, "\" is 
instead ",
                     new _DelayedFTLTypeDescription(path));
         }
         final String strPath = ((TemplateScalarModel) path).getAsString();
         if (strPath == null) {
-            throw new _MiscTemplateException(env, "String value of \"path\" 
parameter is null");
+            throw new TemplateException(env, "String value of \"path\" 
parameter is null");
         }
         
         // See whether we need to use a custom response (if we're inside a TTM
@@ -140,7 +140,7 @@ public class IncludePage implements TemplateDirectiveModel {
             inheritParams = true; 
         } else {
             if (!(inheritParamsModel instanceof TemplateBooleanModel)) {
-                throw new _MiscTemplateException(env,
+                throw new TemplateException(env,
                         "\"", INHERIT_PARAMS_PARAM_NAME, "\" should be a 
boolean but it's a(n) ",
                         inheritParamsModel.getClass().getName(), " instead");
             }
@@ -163,7 +163,7 @@ public class IncludePage implements TemplateDirectiveModel {
                 // Convert params to a Map
                 final Object unwrapped = DeepUnwrap.unwrap(paramsModel);
                 if (!(unwrapped instanceof Map)) {
-                    throw new _MiscTemplateException(env,
+                    throw new TemplateException(env,
                             "Expected \"", PARAMS_PARAM_NAME, "\" to unwrap 
into a java.util.Map. It unwrapped into ",
                             unwrapped.getClass().getName(), " instead.");
                 }
@@ -180,7 +180,7 @@ public class IncludePage implements TemplateDirectiveModel {
             request.getRequestDispatcher(strPath).include(wrappedRequest, 
                     wrappedResponse);
         } catch (ServletException e) {
-            throw new _MiscTemplateException(e, env);
+            throw new TemplateException(e, env);
         }
     }
 

http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/22de04e9/freemarker-servlet/src/main/java/org/apache/freemarker/servlet/jsp/JspTagModelBase.java
----------------------------------------------------------------------
diff --git 
a/freemarker-servlet/src/main/java/org/apache/freemarker/servlet/jsp/JspTagModelBase.java
 
b/freemarker-servlet/src/main/java/org/apache/freemarker/servlet/jsp/JspTagModelBase.java
index bf2a433..86b7d7e 100644
--- 
a/freemarker-servlet/src/main/java/org/apache/freemarker/servlet/jsp/JspTagModelBase.java
+++ 
b/freemarker-servlet/src/main/java/org/apache/freemarker/servlet/jsp/JspTagModelBase.java
@@ -38,7 +38,6 @@ import org.apache.freemarker.core.TemplateException;
 import org.apache.freemarker.core._DelayedJQuote;
 import org.apache.freemarker.core._DelayedShortClassName;
 import org.apache.freemarker.core._ErrorDescriptionBuilder;
-import org.apache.freemarker.core._MiscTemplateException;
 import org.apache.freemarker.core._TemplateModelException;
 import org.apache.freemarker.core.model.ObjectWrapperAndUnwrapper;
 import org.apache.freemarker.core.model.TemplateHashModelEx2;
@@ -87,7 +86,7 @@ class JspTagModelBase {
                         try {
                             ((DynamicAttributes) 
tag).setDynamicAttribute(null, paramName, argArray[0]);
                         } catch (JspException e) {
-                            throw new _MiscTemplateException(
+                            throw new TemplateException(
                                     "Failed to set JSP tag dynamic attribute 
", new _DelayedJQuote(paramName), ".",
                                     e);
                         }

Reply via email to