[ 
https://issues.apache.org/jira/browse/MATH-195?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12576742#action_12576742
 ] 

Luc Maisonobe commented on MATH-195:
------------------------------------

The main inconsistencies come from Mantissa, I apologize for that.

The underlying principles for exception handling in Mantissa were that business 
domain exception (i.e. mathematics related like convergence or the likes) 
should be checked exception. These kind of errors may appear in perfectly valid 
code if given bad or insufficient data. Hence, these are expected errors and 
handling them appropriately in calling code is mandatory. In Mantissa spirit, 
unchecked exception were reserved for "impossible cases" (think defensive 
programming in switch/case code for example).

I still believe these principles are valid, but consistency with [math] is more 
important. So considering the case above, I agree with Phil's comments and 
would go to an unchecked exception hierarchy starting at 
IllegalArgumentException. However, it is important to have these exceptions 
documented in the javadoc, even if they become unchecked.

> Inconsistencies in the Exception hierarchy
> ------------------------------------------
>
>                 Key: MATH-195
>                 URL: https://issues.apache.org/jira/browse/MATH-195
>             Project: Commons Math
>          Issue Type: Improvement
>    Affects Versions: 1.1, 1.2, 2.0, Nightly Builds
>            Reporter: Thomas Chust
>            Assignee: Brent Worden
>            Priority: Minor
>             Fix For: 2.0
>
>   Original Estimate: 0.17h
>  Remaining Estimate: 0.17h
>
> I think there are some inconsistencies in the hierarchy of exceptions used by 
> the Commons Math library which could easily be fixed:
>   - org.apache.commons.math.linear.MatrixIndexException should really be a 
> subclass of
>     java.lang.IndexOutOfBoundsException.
>   - Either org.apache.commons.math.linear.InvalidMatrixException should be 
> checked or
>     org.apache.commons.math.random.NotPositiveDefiniteMatrixException and
>     org.apache.commons.math.geometry.NotARotationMatrixException should be 
> unchecked, but in any case the latter two
>     should be subclasses of the former. An unchecked InvalidMatrixException 
> should probably be a subclass of
>     java.lang.ArithmeticException while a checked InvalidMatrixException 
> should be a subclass of
>     org.apache.commons.math.MathException.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.

Reply via email to