You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@freemarker.apache.org by dd...@apache.org on 2017/08/19 22:10:20 UTC

[1/3] incubator-freemarker git commit: Minor error message fixes/improvements.

Repository: incubator-freemarker
Updated Branches:
  refs/heads/2.3-gae 056bf1cd7 -> 94a3c9998


Minor error message fixes/improvements.


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

Branch: refs/heads/2.3-gae
Commit: 08aa7896ae9fd17e1b1a38b0bfd9a2eacaf4b54b
Parents: 056bf1c
Author: ddekany <dd...@apache.org>
Authored: Sun Aug 20 00:08:05 2017 +0200
Committer: ddekany <dd...@apache.org>
Committed: Sun Aug 20 00:08:05 2017 +0200

----------------------------------------------------------------------
 .../freemarker/core/BuiltInsForStringsEncoding.java | 16 ++++++++--------
 .../freemarker/core/BuiltInsForStringsRegexp.java   | 12 +++++++-----
 src/main/java/freemarker/core/Macro.java            |  3 ++-
 .../ext/beans/ClassBasedModelFactory.java           |  5 ++++-
 .../freemarker/template/GeneralPurposeNothing.java  |  2 +-
 5 files changed, 22 insertions(+), 16 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/08aa7896/src/main/java/freemarker/core/BuiltInsForStringsEncoding.java
----------------------------------------------------------------------
diff --git a/src/main/java/freemarker/core/BuiltInsForStringsEncoding.java b/src/main/java/freemarker/core/BuiltInsForStringsEncoding.java
index d6c2e12..3cfb241 100644
--- a/src/main/java/freemarker/core/BuiltInsForStringsEncoding.java
+++ b/src/main/java/freemarker/core/BuiltInsForStringsEncoding.java
@@ -22,6 +22,7 @@ package freemarker.core;
 import java.io.UnsupportedEncodingException;
 import java.util.List;
 
+import freemarker.template.Configuration;
 import freemarker.template.SimpleScalar;
 import freemarker.template.TemplateMethodModel;
 import freemarker.template.TemplateModel;
@@ -177,14 +178,13 @@ class BuiltInsForStringsEncoding {
                 String cs = env.getEffectiveURLEscapingCharset();
                 if (cs == null) {
                     throw new _TemplateModelException(
-                            "To do URL encoding, the framework that encloses "
-                            + "FreeMarker must specify the output encoding "
-                            + "or the URL encoding charset, so ask the "
-                            + "programmers to fix it. Or, as a last chance, "
-                            + "you can set the url_encoding_charset setting in "
-                            + "the template, e.g. "
-                            + "<#setting url_escaping_charset='ISO-8859-1'>, or "
-                            + "give the charset explicitly to the buit-in, e.g. "
+                            "To do URL encoding, the framework that encloses FreeMarker must specify the \"",
+                            Configuration.OUTPUT_ENCODING_KEY, "\" setting or the \"",
+                            Configuration.URL_ESCAPING_CHARSET_KEY,
+                            "\" setting, so ask the programmers to set them. Or, as a last chance, you can set the "
+                            + "url_encoding_charset setting in the template, e.g. <#setting ",
+                            Configuration.URL_ESCAPING_CHARSET_KEY,
+                            "='ISO-8859-1'>, or give the charset explicitly to the built-in, e.g. "
                             + "foo?url('ISO-8859-1').");
                 }
                 try {

http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/08aa7896/src/main/java/freemarker/core/BuiltInsForStringsRegexp.java
----------------------------------------------------------------------
diff --git a/src/main/java/freemarker/core/BuiltInsForStringsRegexp.java b/src/main/java/freemarker/core/BuiltInsForStringsRegexp.java
index c2c054e..584833d 100644
--- a/src/main/java/freemarker/core/BuiltInsForStringsRegexp.java
+++ b/src/main/java/freemarker/core/BuiltInsForStringsRegexp.java
@@ -196,7 +196,7 @@ class BuiltInsForStringsRegexp {
                         try {
                             return new SimpleScalar(firedEntireInputMatcher.group(i));
                         } catch (Exception e) {
-                            throw new _TemplateModelException(e, "Failed to read match group");
+                            throw new _TemplateModelException(e, "Failed to read regular expression match group");
                         }
                     }
                     
@@ -204,7 +204,7 @@ class BuiltInsForStringsRegexp {
                         try {
                             return firedEntireInputMatcher.groupCount() + 1;
                         } catch (Exception e) {
-                            throw new _TemplateModelException(e, "Failed to get match group count");
+                            throw new _TemplateModelException(e, "Failed to get regular expression match group count");
                         }
                     }
                     
@@ -255,7 +255,9 @@ class BuiltInsForStringsRegexp {
                     public TemplateModel next() throws TemplateModelException {
                         final ArrayList matchingInputParts = RegexMatchModel.this.matchingInputParts;
                         if (matchingInputParts == null) {
-                            if (!hasFindInfo) throw new _TemplateModelException("There were no more matches");
+                            if (!hasFindInfo) {
+                                throw new _TemplateModelException("There were no more regular expression matches");
+                            }
                             MatchWithGroups result = new MatchWithGroups(input, matcher);
                             nextIdx++;
                             hasFindInfo = matcher.find();
@@ -264,7 +266,7 @@ class BuiltInsForStringsRegexp {
                             try {
                                 return (TemplateModel) matchingInputParts.get(nextIdx++);
                             } catch (IndexOutOfBoundsException e) {
-                                throw new _TemplateModelException(e, "There were no more matches");
+                                throw new _TemplateModelException(e, "There were no more regular expression matches");
                             }
                         }
                     }
@@ -283,7 +285,7 @@ class BuiltInsForStringsRegexp {
                         try {
                             return (TemplateModel) matchingInputParts.get(nextIdx++);
                         } catch (IndexOutOfBoundsException e) {
-                            throw new _TemplateModelException(e, "There were no more matches");
+                            throw new _TemplateModelException(e, "There were no more regular expression matches");
                         }
                     }
                 };

http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/08aa7896/src/main/java/freemarker/core/Macro.java
----------------------------------------------------------------------
diff --git a/src/main/java/freemarker/core/Macro.java b/src/main/java/freemarker/core/Macro.java
index 53756df..ef657ac 100644
--- a/src/main/java/freemarker/core/Macro.java
+++ b/src/main/java/freemarker/core/Macro.java
@@ -210,7 +210,8 @@ public final class Macro extends TemplateElement implements TemplateModel {
                             boolean argWasSpecified = localVars.containsKey(argName);
                             throw new _MiscTemplateException(env,
                                     new _ErrorDescriptionBuilder(
-                                            "When calling macro ", new _DelayedJQuote(name), 
+                                            "When calling ", (isFunction() ? "function" : "macro"), " ",
+                                            new _DelayedJQuote(name), 
                                             ", required parameter ", new _DelayedJQuote(argName),
                                             " (parameter #", Integer.valueOf(i + 1), ") was ", 
                                             (argWasSpecified

http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/08aa7896/src/main/java/freemarker/ext/beans/ClassBasedModelFactory.java
----------------------------------------------------------------------
diff --git a/src/main/java/freemarker/ext/beans/ClassBasedModelFactory.java b/src/main/java/freemarker/ext/beans/ClassBasedModelFactory.java
index 1395b8e..5d9ae81 100644
--- a/src/main/java/freemarker/ext/beans/ClassBasedModelFactory.java
+++ b/src/main/java/freemarker/ext/beans/ClassBasedModelFactory.java
@@ -24,6 +24,8 @@ import java.util.Map;
 import java.util.Set;
 import java.util.concurrent.ConcurrentHashMap;
 
+import freemarker.core._DelayedJQuote;
+import freemarker.core._TemplateModelException;
 import freemarker.template.TemplateHashModel;
 import freemarker.template.TemplateModel;
 import freemarker.template.TemplateModelException;
@@ -49,7 +51,8 @@ abstract class ClassBasedModelFactory implements TemplateHashModel {
             if (e instanceof TemplateModelException) {
                 throw (TemplateModelException) e;
             } else {
-                throw new TemplateModelException(e);
+                throw new _TemplateModelException(e,
+                        "Failed to get valeu for key ", new _DelayedJQuote(key), "; see cause exception.");
             }
         }
     }

http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/08aa7896/src/main/java/freemarker/template/GeneralPurposeNothing.java
----------------------------------------------------------------------
diff --git a/src/main/java/freemarker/template/GeneralPurposeNothing.java b/src/main/java/freemarker/template/GeneralPurposeNothing.java
index 8023bd8..cb2d3af 100644
--- a/src/main/java/freemarker/template/GeneralPurposeNothing.java
+++ b/src/main/java/freemarker/template/GeneralPurposeNothing.java
@@ -58,7 +58,7 @@ implements TemplateBooleanModel, TemplateScalarModel, TemplateSequenceModel, Tem
     }
 
     public TemplateModel get(int i) throws TemplateModelException {
-        throw new TemplateModelException("Empty list");
+        throw new TemplateModelException("Can't get item from an empty sequence.");
     }
 
     public TemplateModel get(String key) {


[3/3] incubator-freemarker git commit: (JavaDoc typos)

Posted by dd...@apache.org.
(JavaDoc typos)


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

Branch: refs/heads/2.3-gae
Commit: 94a3c9998d1e52abe3cd78ba1a22335e91b7b736
Parents: a923ee8
Author: ddekany <dd...@apache.org>
Authored: Sun Aug 20 00:10:05 2017 +0200
Committer: ddekany <dd...@apache.org>
Committed: Sun Aug 20 00:10:05 2017 +0200

----------------------------------------------------------------------
 src/main/java/freemarker/template/utility/Constants.java | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/94a3c999/src/main/java/freemarker/template/utility/Constants.java
----------------------------------------------------------------------
diff --git a/src/main/java/freemarker/template/utility/Constants.java b/src/main/java/freemarker/template/utility/Constants.java
index ef8333d..056c8a8 100644
--- a/src/main/java/freemarker/template/utility/Constants.java
+++ b/src/main/java/freemarker/template/utility/Constants.java
@@ -39,8 +39,8 @@ import freemarker.template.TemplateSequenceModel;
  * Frequently used constant {@link TemplateModel} values.
  * 
  * <p>These constants should be stored in the {@link TemplateModel}
- * sub-interfaces, but for bacward compatibility they are stored here instead.
- * Starting from FreeMarker 2.4 they should be copyed (not moved!) into the
+ * sub-interfaces, but for backward compatibility they are stored here instead.
+ * Starting from FreeMarker 2.4 they should be copied (not moved!) into the
  * {@link TemplateModel} sub-interfaces, and this class should be marked as
  * deprecated.</p>
  */


[2/3] incubator-freemarker git commit: (Removed unused EvalUtil.modelToNumber call)

Posted by dd...@apache.org.
(Removed unused EvalUtil.modelToNumber call)


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

Branch: refs/heads/2.3-gae
Commit: a923ee8fa24679746a48fe7c3a60a7a316d076d2
Parents: 08aa789
Author: ddekany <dd...@apache.org>
Authored: Sun Aug 20 00:08:47 2017 +0200
Committer: ddekany <dd...@apache.org>
Committed: Sun Aug 20 00:08:47 2017 +0200

----------------------------------------------------------------------
 src/main/java/freemarker/core/BuiltInsForMultipleTypes.java | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/a923ee8f/src/main/java/freemarker/core/BuiltInsForMultipleTypes.java
----------------------------------------------------------------------
diff --git a/src/main/java/freemarker/core/BuiltInsForMultipleTypes.java b/src/main/java/freemarker/core/BuiltInsForMultipleTypes.java
index 98c3a4d..2adcebc 100644
--- a/src/main/java/freemarker/core/BuiltInsForMultipleTypes.java
+++ b/src/main/java/freemarker/core/BuiltInsForMultipleTypes.java
@@ -691,9 +691,7 @@ class BuiltInsForMultipleTypes {
         TemplateModel _eval(Environment env) throws TemplateException {
             TemplateModel model = target.eval(env);
             if (model instanceof TemplateNumberModel) {
-                TemplateNumberModel numberModel = (TemplateNumberModel) model;
-                Number num = EvalUtil.modelToNumber(numberModel, target);
-                return new NumberFormatter(numberModel, env);
+                return new NumberFormatter((TemplateNumberModel) model, env);
             } else if (model instanceof TemplateDateModel) {
                 TemplateDateModel dm = (TemplateDateModel) model;
                 return new DateFormatter(dm, env);