Hi.

> > I am assuming that the main difference between using the "ExceptionContext"
> > and passing information in the exception's constructor is that in the
> > latter, the information will unconditionally appear in the string returned
> > by "getMessage". The contents of the "ExceptionContext" must be retrieved
> > manually because, as is the case for iterative solvers, it could lead to a
> > huge message.
> >
> Yes. Or even in some cases to "impossible" messages since it is
> totally unthinkable to compute the entries of the matrix underlying
> the general linear operator. In fact, for debugging purposes, printing
> the operator is not in my view necessary. For example, if the
> preconditioned conjugate gradient throws a
> NonPositiveDefiniteLinearOperatorException, I just need to know which
> one of the operator or its preconditioner was found not to be positive
> definite.

Do you mean that the context info for a (hyptohetical) method like
  doSomething(LinearOperator a, LinearOperator b)
would be like
  offending operator: a
or
  offending operator: b
?

If so, is it not enough to just throw the exception? Won't it be obvious
which operator is "offending" by looking at the line number in the stack
trace?

> >
> > Thus, when debugging an application, one can catch the exception and loop
> > over the context keys using the "getKeys()" method, without needing to need
> > the key names in advance. [Thus I would keep the key names "private".]
> >
> OK, I understand. But we *do* document the keys, don't we? For
> example, would the Javadoc of the Conjugate Gradient method state
> which keys are used for what purpose?

In principle it would not hurt to have more detailed documentation.
Alternatively, we could introduce a general comment that "Additional
information on the failure is available in the exception context".


Best,
Gilles

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

Reply via email to