commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From S├ębastien Brisard <>
Subject Re: [math] Consistent use of ExceptionContext [was "using the ExceptionContext facility"]
Date Fri, 26 Aug 2011 06:15:15 GMT

> One thing that I think we all agree on; however, is that we should not be
> designing exceptions or APIs that throw exceptions with the intent that
> applications catching exceptions should parse the messages or search
> the message content for specific strings.
I do apologize, I am not sure I fully understand. Please let me try
again. I agree, parsing e.getMessage() would be horrible, but that was
not what I had in mind.

Let's say that a NonPositiveDefiniteLinearOperatorException e is
raised, and I want to retrieve the operator in question. One way to do
it would be to have a getter
In MATH-581, following the discussion entitled "Implementation of
Conjugate Gradient (MATH-581)" (started aug, 4), we finally went for
the more flexible
e.getContext().getValue("offending operator")

The issue then is a proper handling of the key names ("offending
operator" in the present case). Should the key names be assigned
arbitrarily by the method which throws the exception, or stored (as a
constant String) in the exception itself. My point is that in some
circumstances, it is possible to have the exception store "typical"
keys, which can be consistently used by everyone throwing such an
exception, with the further possibility to add supplementary context
to this exception, with freely chosen key names.

Is it what you understood from my previous message?
Best regards,

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

View raw message