From: Dominik Stadler Date: Mon, 15 Feb 2016 07:41:47 +0000 (+0000) Subject: Improve error messages to state which bounds are exceeded X-Git-Tag: REL_3_14_FINAL~40 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=6979efe4745da5825bbc77a8e15428abd4bbc407;p=poi.git Improve error messages to state which bounds are exceeded git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1730463 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/src/ooxml/java/org/apache/poi/util/IdentifierManager.java b/src/ooxml/java/org/apache/poi/util/IdentifierManager.java index 77fe79c630..4b57e77707 100644 --- a/src/ooxml/java/org/apache/poi/util/IdentifierManager.java +++ b/src/ooxml/java/org/apache/poi/util/IdentifierManager.java @@ -54,8 +54,7 @@ public class IdentifierManager { */ public IdentifierManager(long lowerbound, long upperbound) { if (lowerbound > upperbound) { - String message = "lowerbound must not be greater than upperbound"; - throw new IllegalArgumentException(message); + throw new IllegalArgumentException("lowerbound must not be greater than upperbound, had " + lowerbound + " and " + upperbound); } else if (lowerbound < MIN_ID) { String message = "lowerbound must be greater than or equal to " + Long.toString(MIN_ID); @@ -64,10 +63,9 @@ public class IdentifierManager { else if (upperbound > MAX_ID) { /* * while MAX_ID is Long.MAX_VALUE, this check is pointless. But if - * someone subclasses / tweaks the limits, this check if fine. + * someone subclasses / tweaks the limits, this check is fine. */ - String message = "upperbound must be less thean or equal " + Long.toString(MAX_ID); - throw new IllegalArgumentException(message); + throw new IllegalArgumentException("upperbound must be less than or equal to " + Long.toString(MAX_ID) + " but had " + upperbound); } this.lowerbound = lowerbound; this.upperbound = upperbound; @@ -77,7 +75,7 @@ public class IdentifierManager { public long reserve(long id) { if (id < lowerbound || id > upperbound) { - throw new IllegalArgumentException("Value for parameter 'id' was out of bounds"); + throw new IllegalArgumentException("Value for parameter 'id' was out of bounds, had " + id + ", but should be within [" + lowerbound + ":" + upperbound + "]"); } verifyIdentifiersLeft(); @@ -161,7 +159,7 @@ public class IdentifierManager { */ public boolean release(long id) { if (id < lowerbound || id > upperbound) { - throw new IllegalArgumentException("Value for parameter 'id' was out of bounds"); + throw new IllegalArgumentException("Value for parameter 'id' was out of bounds, had " + id + ", but should be within [" + lowerbound + ":" + upperbound + "]"); } if (id == upperbound) {