On 9 July 2010 18:35, Gilles Sadowski <gil...@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-unsubscr...@commons.apache.org
> For additional commands, e-mail: dev-h...@commons.apache.org
>
>

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

Reply via email to