-
Enhancement
-
Resolution: Fixed
-
P4
-
None
-
b14
-
generic
-
generic
A DESCRIPTION OF THE PROBLEM :
java.util.Currency.getInstance method throw IllegalArgumentException without any error message. As an enhancement a more meaningful error message could be produce.
Before :
boolean found = false;
if (currencyCode.length() != 3) {
throw new IllegalArgumentException();
}
After :
boolean found = false;
if (currencyCode.length() != 3) {
throw new IllegalArgumentException("Currency code not 3 characters length");
}
Before :
if (!found) {
OtherCurrencyEntry ocEntry = OtherCurrencyEntry.findEntry(currencyCode);
if (ocEntry == null) {
throw new IllegalArgumentException("Currency code not found");
}
...
}
After :
if (!found) {
OtherCurrencyEntry ocEntry = OtherCurrencyEntry.findEntry(currencyCode);
if (ocEntry == null) {
throw new IllegalArgumentException("Currency code not found");
}
...
}
As a comparable in java.time.format.DateTimeFormatter some error message are added in the exception message :
public TemporalAccessor parseBest(CharSequence text, TemporalQuery<?>... queries) {
Objects.requireNonNull(text, "text");
Objects.requireNonNull(queries, "queries");
if (queries.length < 2) {
throw new IllegalArgumentException("At least two queries must be specified");
}
java.util.Currency.getInstance method throw IllegalArgumentException without any error message. As an enhancement a more meaningful error message could be produce.
Before :
boolean found = false;
if (currencyCode.length() != 3) {
throw new IllegalArgumentException();
}
After :
boolean found = false;
if (currencyCode.length() != 3) {
throw new IllegalArgumentException("Currency code not 3 characters length");
}
Before :
if (!found) {
OtherCurrencyEntry ocEntry = OtherCurrencyEntry.findEntry(currencyCode);
if (ocEntry == null) {
throw new IllegalArgumentException("Currency code not found");
}
...
}
After :
if (!found) {
OtherCurrencyEntry ocEntry = OtherCurrencyEntry.findEntry(currencyCode);
if (ocEntry == null) {
throw new IllegalArgumentException("Currency code not found");
}
...
}
As a comparable in java.time.format.DateTimeFormatter some error message are added in the exception message :
public TemporalAccessor parseBest(CharSequence text, TemporalQuery<?>... queries) {
Objects.requireNonNull(text, "text");
Objects.requireNonNull(queries, "queries");
if (queries.length < 2) {
throw new IllegalArgumentException("At least two queries must be specified");
}