commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Gilles Sadowski <gil...@harfang.homelinux.org>
Subject Re: [math] LocalizedFormats.DIVISION_BY_ZERO?
Date Mon, 27 Feb 2012 10:24:46 GMT
On Mon, Feb 27, 2012 at 07:28:30AM +0100, S├ębastien Brisard wrote:
> Hello,
> while working on MATH-755, I've noticed that there is no error message
> corresponding to a division by zero. So for the time being, when such
> a situation occurs, I use "ZERO_NOT_ALLOWED", but I was considering
> adding an entry DIVISION_BY_ZERO to LocalizedFormats. What do you
> think? I could do this fairly quickly, in order not to interfere with
> the current release process.

There are several (overlapping) entries, a.o.:

    FRACTION("fraction"), /* keep */
    DENOMINATOR("denominator"), /* keep */
    ZERO_DENOMINATOR("denominator must be different from 0"),
    ZERO_DENOMINATOR_IN_FRACTION("zero denominator in fraction {0}/{1}"),
    ZERO_FRACTION_TO_DIVIDE_BY("the fraction to divide by must not be zero: {0}/{1}"),
    ZERO_NOT_ALLOWED("zero not allowed here");
    IDENTICAL_ABSCISSAS_DIVISION_BY_ZERO("identical abscissas x[{0}] == x[{1}] == {2} cause
division by zero"),

My preference would be to rationalize, using the "ExceptionContext" to add
more information where needed. E.g. something like:

   MathArithmeticException iae = new MathArithmeticException(LocalizedFormats.FRACTION);
   iae.getContext().addMessage(LocalizedFormats.DENOMINATOR);
   iae.getContext().addMessage(LocalizedFormats.ZERO_NOT_ALLOWED);

But, if "DIVISION_BY_ZERO" is going to be used in several places, it might
be good to add it. [Still, the redundant entries should at some point be
removed (their use being replaced by a combination of the basic ones).]


Best,
Gilles

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


Mime
View raw message