commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Luc Maisonobe <...@spaceroots.org>
Subject Re: [math] MathIllegalArgumentException
Date Sun, 27 Oct 2013 09:35:45 GMT
Le 21/10/2013 22:58, Ted Dunning a écrit :
> +1
> 
> The overwhelming standard practice is to use a plausible exception type
> (such as some form of IllegalArgumentException) with a message.
> 
> 
> 
> 
> On Mon, Oct 21, 2013 at 5:24 PM, Phil Steitz <phil.steitz@gmail.com> wrote:
> 
>> I hate to open this can of worms again, but the following is just
>> too painful for me to ignore.  From recent mods to
>> BinomialConfidenceInterval javadoc:
>>
>>      * @throws NumberIsTooLargeException if {@code numberOfSuccesses
>>> numberOfTrials}.
>>
>> The "NumberIsTooLarge" exception adds exactly zero to what would be
>> more natural - just throw MathIAE.  Fortunately, the message is at
>> least still there in the code:
>>
>> if (numberOfSuccesses > numberOfTrials) {
>>             throw new
>>
>> NumberIsTooLargeException(LocalizedFormats.NUMBER_OF_SUCCESS_LARGER_THAN_POPULATION_SIZE,
>>                                                 numberOfSuccesses,
>> numberOfTrials, true);
>>  }
>>
>> The "NumberIsTooLarge" is ridiculous.  What number?  Why isn't the
>> second number "too small?"  If we really are going insist on
>> defining and advertising lots of little subexceptions to MathIAE, we
>> need to define appropriate ones, or just leave MathIAE.  My vote is
>> to just allow throwing MathIAE with a descriptive message.  If we
>> insist on adding subexceptions for everything, in this case, we need
>> something like
>>
>> SubsetSizeException
>>
>> and in another set of changes that I am about to commit that will
>> end up similarly mangled,  I will need
>>
>> InsufficientDataException
>>
>> I would like to get full community input on this topic for once and
>> for all and either add a slew of new exceptions so what we throw is
>> meaningful in the context of the caller, or just allow MathIAE to be
>> thrown directly.
>>
>> So please all be brief and specify your preference for one of the
>> two options below:
>>
>> 0) allow MathIAE to be thrown directly with an informative message

+1 to the simple MathIAE with an informative message.

best regards,
Luc


>>
>> 1) define caller-meaningful exceptions for situations such as
>> insufficient data, invalid subset size, invalid probability, invalid
>> interval, ...
>>
>> I would much prefer 0), but if consensus is 1), I will start adding
>> exceptions so what we throw is meaningful and open a ticket to clean
>> up for 4.0.
>>
>> Phil
>>
>> ---------------------------------------------------------------------
>> 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