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/25 23:39:34 UTC
[08/19] incubator-freemarker git commit: Minor error message
fixes/improvements.
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
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) {