commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Gilles <>
Subject Re: [math] ArithmeticUtils subAndCheck try catch
Date Sat, 19 Dec 2015 10:32:36 GMT
On Fri, 18 Dec 2015 19:16:54 -0600, Ole Ersoy wrote:
> The (This is nit picky) ArithmeticUtils subAndCheck uses a message
> template that is meant for addition.  Should it catch and rethrow the
> exception with a subtraction template?  This is how the exception is
> thrown (Line 470):
> throw new
> MathArithmeticException(LocalizedFormats.OVERFLOW_IN_ADDITION, a, 
> -b);

My opinion is that there are too many "independent" messages that 
describe related families of problems.
My approach has been to try and mix and match "elementary" blocks in 
to reduce the number of messages to be localized.
I admit that the end result is sometimes not very nice to read, but the 
is to simplify the management of this unnecessarily huge list.
There must be a better way than manipulating those string templates...

In short, I would not like yet another message.  Personally, for lack 
a better messaging framework, I'd add a new exception:
   MathArithmeticOperationException extends MathArithmeticException { 
/** ... */ }
and its instantiation would be something like:
   new MathArithmeticOperationException(LocalizedFormats.ADDITION,
                                        LocalizedFormats.OVERFLOW, a, 
   new MathArithmeticOperationException(LocalizedFormats.SUBTRACTION,
                                        LocalizedFormats.OVERFLOW, a, 

Or, with the existing code, it is possible to add this information to 


To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message