Hi Stephen,

Stephen Colebourne wrote:

> On 2 July 2011 15:28, Jörg Schaible <joerg.schai...@gmx.de> wrote:
>> Can somebody else give the ContextedException stuff a review? I used in
>> the meanwhile a copy of it in a project, but a method name is bugging me.
> 
> The structure looks reasonable to me.
> 
> While you could rename replaceValue() to setValue(), I don't see that
> change as essential. replaceValue() is utterly clear about what it
> will do, whereas setValue() is slightly more vague. So, I think I'd
> just leave it as is.

Sorry, why is setValue more vague - isn't it the other way round?

See, if I am in a recursion, I don't want to keep track whether I am 
catching the CtxEx the first time or not. With the current API I have to 
write:


try {
 ...
} catch(ContextException ex) {
 // the next call might be simply ignored when called the 2nd time 
 ex.addValue("Current Handler", handler.class.getName());
 // replace might silently ignore the call if the label is not yet present
 if (ex.getLables().contains("Current Line")) {
  ex.replaceValue("Current Line", line);
 } else {
  ex.addValue("Current Line", line);
 }
 throw ex;
}

In contrast "setValue" means "set the value and replace any existing" while 
"addValue" actually means "add the value":

try {
 ...
} catch(ContextException ex) {
 throw ex.addValue("Current Handler", handler.class.getName())
  .setValue("Current Line", line);
}

Sorry, but the first version does simply not make sense to me.

- Jörg


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

Reply via email to