commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sebb <seb...@gmail.com>
Subject Re: svn commit: r962515 - in /commons/proper/math/trunk/src/main: java/org/apache/commons/math/analysis/polynomials/ java/org/apache/commons/math/exception/ java/org/apache/commons/math/random/ java/org/apache/commons/math/util/ resources/META-INF/lo
Date Fri, 09 Jul 2010 18:04:34 GMT
On 9 July 2010 18:35, Gilles Sadowski <gilles@harfang.homelinux.org> wrote:
>> >     public PolynomialFunction(double c[]) {
>> >         super();
>> >         if (c.length < 1) {
>> > -            throw MathRuntimeException.createIllegalArgumentException(LocalizedFormats.EMPTY_POLYNOMIALS_COEFFICIENTS_ARRAY);
>> > +            throw new NotStrictlyPositiveException(LocalizedFormats.EMPTY_POLYNOMIALS_COEFFICIENTS_ARRAY,
>> > +                                                  
c.length);
>> >         }
>>
>> Seems very odd to me to reject an empty array parameter with
>> "NotStrictlyPositiveException".
>
> It just means that a 0 length is not allowed.

Or it could potentially mean that one of the array entries was 0.

The point is that the cause of the problem is not at all obvious from
the exception class name.

IMO it's less helpful than IAE.

>> I would expect that to be reserved for numeric data passed as a
>> parameter or as an array entry.
>>
>> IllegalArgument seems much clearer to me;
>
> "NotStrictlyPositiveException" is a subclass of "IllegalArgumentException".

Irrelevant, since what is confusing here is the classname of the exception.

>> alternatively one could
>> perhaps create an EmptyArrayNotAllowedException, if this is a common
>> requirement.
>
> Could be too.
>
>
> Gilles
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
> For additional commands, e-mail: dev-help@commons.apache.org
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
For additional commands, e-mail: dev-help@commons.apache.org


Mime
View raw message