[
https://issues.apache.org/jira/browse/MATH-542?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13003190#comment-13003190
]
Gilles commented on MATH-542:
-----------------------------
Of course an object like "ExceptionContext" could store arbitrary (key, value)
pairs.
But if users want to use "ExceptionContext", they can use the real thing ;-)
i.e. depend on [Lang] for that functionality. We don't need that _in_ CM.
What we need to do in CM is provide a fully informative localized message. I
know it is a burden for users to implement "Localizable" but, IIRC, you said
that you were doing exactly that in your application (because you need
localization).
So to achieve that goal in the simplest way, "addMessage" is all that's needed.
Allowing arbitrary types for the key will go in the way of the above goal.
Indeed, how do you localize the message string if you don't have a
"Localizable" key? I know that we _could_ do it (with "instanceof") but I think
that we wouldn't do a favour to CM users: When some code layers insert
non-localizable messages/objects, it will result in a patchwork of different
languages in the final display. And if we don't display the non-localizable
info, then we contradict part the stated goal (full information).
Again, I recommend to keep it simple at first, until a clear-cut use-case shows
that some functionality is missing.
> Allow the addition of multiple messages to the exceptions generated by CM
> -------------------------------------------------------------------------
>
> Key: MATH-542
> URL: https://issues.apache.org/jira/browse/MATH-542
> Project: Commons Math
> Issue Type: New Feature
> Reporter: Gilles
> Assignee: Gilles
> Priority: Minor
> Labels: api-change
> Fix For: 3.0
>
>
> Borrowing on the idea of "ExceptionContext" implemented in [Lang],
> "MathRuntimeException" (base class of all exceptions generated from CM) will
> be enhanced so that an unlimited number of (localized) messages can be added
> to an exception object.
> The "MathThrowable" interface (implemented by "MathRuntimeException") will
> contain the following new method:
> {code}
> /**
> * Sets a message.
> *
> * @param pattern Message pattern.
> * @param arguments Values for replacing the placeholders in the message
> * pattern.
> */
> public void addMessage(Localizable pattern,
> Object ... arguments);
> {code}
--
This message is automatically generated by JIRA.
-
For more information on JIRA, see: http://www.atlassian.com/software/jira