This is the mail archive of the java-patches@gcc.gnu.org mailing list for the Java project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Patch: java.text.MessageFormat - fix for PR 2429 ?


Hi list,


I wrote a little patch to fix PR 2429. This adds messages to the execeptions 
thrown in MessageFormat class.

Please review and comment. Okay for commit ?


Michael


2004-01-11  Michael Koch  <konqueror@gmx.de>

	* java/text/MessageFormat.java:
	Added descriptions to exceptions.
	This fixes PR libgcj/2429.

Index: java/text/MessageFormat.java
===================================================================
RCS file: /cvs/gcc/gcc/libjava/java/text/MessageFormat.java,v
retrieving revision 1.14
diff -u -b -B -r1.14 MessageFormat.java
--- java/text/MessageFormat.java	19 Dec 2003 09:53:06 -0000	1.14
+++ java/text/MessageFormat.java	10 Jan 2004 23:00:32 -0000
@@ -170,7 +170,7 @@
 	else if (c == '{')
 	  break;
 	else if (c == '}')
-	  throw new IllegalArgumentException ();
+	  throw new IllegalArgumentException("Found '}' without '{'");
 	else
 	  buffer.append(c);
       }
@@ -245,7 +245,7 @@
       }
     catch (NumberFormatException nfx)
       {
-	throw new IllegalArgumentException ();
+	throw new IllegalArgumentException("Failed to parse integer string");
       }
 
     // Extract the element format.
@@ -264,7 +264,7 @@
 
     // 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 @@
     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 @@
 	  {
 	    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 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];

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]