diff options
author | Michael Koch <konqueror@gmx.de> | 2004-01-14 19:45:11 +0000 |
---|---|---|
committer | Michael Koch <mkoch@gcc.gnu.org> | 2004-01-14 19:45:11 +0000 |
commit | b3e5b4528dfa0632a4c4eda55b432d1f25de093f (patch) | |
tree | 5f05ab7cbeacdb2c3681cf55a771c99199019791 /libjava/java | |
parent | 47f62b27c8605658db7658421ef56b8d020ed4fb (diff) | |
download | gcc-b3e5b4528dfa0632a4c4eda55b432d1f25de093f.zip gcc-b3e5b4528dfa0632a4c4eda55b432d1f25de093f.tar.gz gcc-b3e5b4528dfa0632a4c4eda55b432d1f25de093f.tar.bz2 |
re PR libgcj/2429 (java.text.MessageFormat should usefully set text on exceptions)
2004-01-14 Michael Koch <konqueror@gmx.de>
* java/text/MessageFormat.java:
Added descriptions to exceptions.
This fixes PR libgcj/2429.
From-SVN: r75877
Diffstat (limited to 'libjava/java')
-rw-r--r-- | libjava/java/text/MessageFormat.java | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/libjava/java/text/MessageFormat.java b/libjava/java/text/MessageFormat.java index e34fe2c..7bb7760 100644 --- a/libjava/java/text/MessageFormat.java +++ b/libjava/java/text/MessageFormat.java @@ -170,7 +170,7 @@ public class MessageFormat extends Format else if (c == '{') break; else if (c == '}') - throw new IllegalArgumentException (); + throw new IllegalArgumentException("Found '}' without '{'"); else buffer.append(c); } @@ -245,7 +245,7 @@ public class MessageFormat extends Format } catch (NumberFormatException nfx) { - throw new IllegalArgumentException (); + throw new IllegalArgumentException("Failed to parse integer string"); } // Extract the element format. @@ -264,7 +264,7 @@ public class MessageFormat extends Format // Advance past the last terminator. if (index >= max || pat.charAt(index) != '}') - throw new IllegalArgumentException (); + throw new IllegalArgumentException("Missing '}' at end of message format"); ++index; // Now fetch trailing string. @@ -349,7 +349,8 @@ public class MessageFormat extends Format for (int i = 0; i < elements.length; ++i) { if (elements[i].argNumber >= arguments.length) - throw new IllegalArgumentException (); + throw new IllegalArgumentException("Not enough arguments given"); + Object thisArg = arguments[elements[i].argNumber]; Format formatter = null; @@ -359,7 +360,8 @@ public class MessageFormat extends Format { if (elements[i].formatClass != null && ! elements[i].formatClass.isInstance(thisArg)) - throw new IllegalArgumentException (); + throw new IllegalArgumentException("Wrong format class"); + formatter = elements[i].format; } else if (thisArg instanceof Number) @@ -596,7 +598,8 @@ public class MessageFormat extends Format public void setFormats (Format[] newFormats) { if (newFormats.length < elements.length) - throw new IllegalArgumentException (); + throw new IllegalArgumentException("Not enough format objects"); + int len = Math.min(newFormats.length, elements.length); for (int i = 0; i < len; ++i) elements[i].setFormat = newFormats[i]; |