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):

https://github.com/apache/commons-math/blob/master/src/main/java/org/apache/commons/math4/util/ArithmeticUtils.java
throw new
MathArithmeticException(LocalizedFormats.OVERFLOW_IN_ADDITION, a, -b);

My opinion is that there are too many "independent" messages that actually
describe related families of problems.
My approach has been to try and mix and match "elementary" blocks in order
to reduce the number of messages to be localized.
I admit that the end result is sometimes not very nice to read, but the idea
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 of
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, b);
or
  new MathArithmeticOperationException(LocalizedFormats.SUBTRACTION,
LocalizedFormats.OVERFLOW, a, b);

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

Regards,
Gilles

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

Reply via email to