This is an automated email from the ASF dual-hosted git repository.
garydgregory pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/commons-text.git
The following commit(s) were added to refs/heads/master by this push:
new d3fd33d4 Better exception messages in
ExtendedMessageFormat.applyPattern(String)
d3fd33d4 is described below
commit d3fd33d4956b7bf6df89f1739ea8b42c4e46d166
Author: Gary Gregory <[email protected]>
AuthorDate: Wed Jul 8 11:26:40 2026 -0400
Better exception messages in ExtendedMessageFormat.applyPattern(String)
Better version of PR #758.
---
src/changes/changes.xml | 1 +
.../java/org/apache/commons/text/ExtendedMessageFormat.java | 10 ++++++----
2 files changed, 7 insertions(+), 4 deletions(-)
diff --git a/src/changes/changes.xml b/src/changes/changes.xml
index dc05b644..632c0441 100644
--- a/src/changes/changes.xml
+++ b/src/changes/changes.xml
@@ -64,6 +64,7 @@ The <action> type attribute can be add,update,fix,remove.
<action type="fix" dev="ggregory" due-to="alhuda, Gary Gregory">Fix
WordUtils.containsAllWords missing words across line breaks (#754).</action>
<action type="fix" dev="ggregory" due-to="alhuda, Gary Gregory">Keep
TextStringBuilder.reverse from splitting surrogate pairs (#756).</action>
<action type="fix" dev="ggregory" due-to="Javid Khan, Gary Gregory">Stop
ExtendedMessageFormat seekNonWs reading past the pattern end (#759).</action>
+ <action type="fix" dev="ggregory" due-to="Gary Gregory, Anik1459">Better
exception messages in ExtendedMessageFormat.applyPattern(String)
(#758).</action>
<!-- ADD -->
<!-- UPDATE -->
<action type="update" dev="ggregory" due-to="Gary Gregory">Bump
org.apache.commons:commons-parent from 93 to 102.</action>
diff --git a/src/main/java/org/apache/commons/text/ExtendedMessageFormat.java
b/src/main/java/org/apache/commons/text/ExtendedMessageFormat.java
index 93c1f3b6..b8b22129 100644
--- a/src/main/java/org/apache/commons/text/ExtendedMessageFormat.java
+++ b/src/main/java/org/apache/commons/text/ExtendedMessageFormat.java
@@ -235,11 +235,13 @@ public class ExtendedMessageFormat extends MessageFormat {
}
foundFormats.add(format);
foundDescriptions.add(format == null ? null :
formatDescription);
- if (foundFormats.size() != fmtCount) {
- throw new IllegalArgumentException("The validated
expression is false");
+ final int foundFormatsSize = foundFormats.size();
+ if (foundFormatsSize != fmtCount) {
+ throw new IllegalArgumentException("Format elements do not
match format count: " + foundFormatsSize + " != " + fmtCount);
}
- if (foundDescriptions.size() != fmtCount) {
- throw new IllegalArgumentException("The validated
expression is false");
+ final int foundDescriptionsSize = foundDescriptions.size();
+ if (foundDescriptionsSize != fmtCount) {
+ throw new IllegalArgumentException("Format descriptions do
not match format count: " + foundDescriptionsSize + " != " + fmtCount);
}
if (c[pos.getIndex()] != END_FE) {
throw new IllegalArgumentException("Unreadable format
element at position " + start);