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

Ole Ersoy commented on MATH-361:
--------------------------------

The one enum per class idea is meant to enable detailed context messages for 
end users.  I'm suggesting that this enum only be used to communicate messages 
for end users.  I, and I think you as well, think that the core CM library 
classes should not use this enum at all.  The core CM library should only use 
the minimal set of Enums that are very generic.  Then if the maintainer of a 
specific class wants to provide additional messages that capture the context of 
a problem to a greater extent, they should go in a separate Enum class that 
matches the class that would have generated the exception with the generic enum.

Note that with this approach, an exception does not necessarily have to be 
generated in order for an application developer to make use of the Enum 
messages accompanying a class.

For instance there may be a "Alpha parameter field" where the user enters a 
number.  If the number is negative, the application pulls a Commons Math 
provided message that says that the "Alpha parameter of the Gamma Distribution 
must always positive".

So the goal of having an Enum per class, is to have all messages that could be 
helpful to an end user ready to go.  The javadoc could then go into further 
detail with respect what would trigger the need to show these messages to the 
end user.  

So for instance the javadoc could say that "if a negative alpha parameter is 
submitted it will trigger a PositiveNumbersOnlyException (With the generic 
"Only positive numbers allowed" message ).  If you are an application 
developer, avoid this exception being triggered by first validating that the 
number is negative, and if it is, show the following message from the 
GammaDistributionEnum class to your user....

> Localization and Error Handling
> -------------------------------
>
>                 Key: MATH-361
>                 URL: https://issues.apache.org/jira/browse/MATH-361
>             Project: Commons Math
>          Issue Type: Improvement
>    Affects Versions: 2.1
>            Reporter: Gilles
>            Priority: Minor
>         Attachments: l10n.tar.gz, res.tar.gz
>
>
> This proposal aims at easing the handling of error during algorithms 
> development, and also enhancing the flexibility of the error reporting 
> (provide meaningful exception classes and run-time selection of the 
> localization formatting).
> More details at 
> [http://www.mail-archive.com/[email protected]/msg14570.html]

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