classpath-patches
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [cp-patches] Currency question


From: Andrew John Hughes
Subject: Re: [cp-patches] Currency question
Date: Thu, 20 Jan 2005 12:06:41 +0000

On Thu, 2005-01-20 at 10:35, Mark Wielaard wrote:
> Hi,
> 
> I started on improving the exception message of Currency to figure out
> what goes wrong in this case:
> http://brutus.apache.org/gump/kaffe/msv/xsdlib/gump_work/build_msv_xsdlib.html
> "java.lang.IllegalArgumentException: The specified country code is
> invalid"
> 
> So I would propose this patch:
> 
> --- java/util/Currency.java     17 Jan 2005 00:59:42 -0000      1.11
> +++ java/util/Currency.java     20 Jan 2005 10:24:01 -0000
> @@ -169,7 +169,8 @@
>      if (countryCode.equals(""))
>        {
>          throw new
> -         IllegalArgumentException("The specified country code is invalid");
> +         IllegalArgumentException("Invalid (empty) country code for locale:"
> +                                  + loc);
>        }
>      /* Construct the key for the currency */
>      currencyKey = countryCode + ".currency";
> 
> But reading the code a bit more it seems that this case is similar to
> when the countryCode for an Locale is null. What would be the
> best/expected approach here?
> 
> Cheers,
> 
> Mark
> 
> ______________________________________________________________________
> _______________________________________________
> Classpath-patches mailing list
> address@hidden
> http://lists.gnu.org/mailman/listinfo/classpath-patches

I'd go with the patch, as it makes the message clearer and it then
becomes obvious that the error is an empty string, rather than just an
arbitrary invalid code.  Please commit.

As for unifying the null and "" cases, this doesn't make sense as the
exception for the null case is a NullPointerException.  A quick check
shows that Sun's implementation also throws an InvalidArgumentException
(but we do better in giving a reason!)

I'm wondering if this is a bug in some of our calling code.

Cheers,
-- 
Andrew :-)

Please avoid sending me Microsoft Office (e.g. Word, PowerPoint) attachments.
See http://www.fsf.org/philosophy/no-word-attachments.html

No software patents in Europe -- http://nosoftwarepatents.com

"Value your freedom, or you will lose it, teaches history.
`Don't bother us with politics' respond those who don't want to learn."
-- Richard Stallman

"We've all been part of the biggest beta test the world has ever known --
Windows"
-- Victor Wheatman, Gartner

Attachment: signature.asc
Description: This is a digitally signed message part


reply via email to

[Prev in Thread] Current Thread [Next in Thread]