commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Jack, Paul" <pj...@sfaf.org>
Subject RE: [Lang] Generic interface for handling exceptions
Date Thu, 01 Aug 2002 16:57:04 GMT
> I wasn't saying that exception callbacks aren't useful.  On the 
> contrary.  I think it is a very worthwhile pattern to use.  What 
> I am saying is that I don't like the generic application of that 
> pattern.  I think it is much better to be specific to get the 
> benefits you list above (exact namings used and precise exception 
> type).
> 
> An additional benefit is the ability to separate distinct types 
> of exception notifications.  For example, if a component wants to
> notify about two different exceptions, they would need to get two 
> different ThrowableHandler implementations, one for each.  While 
> that may not seem so bad, consider a component that wants to notify
> about 30.  It's much easier to add a method than it is to add new 
> class implementations for each case.

You'd only need a new class per exception if you wanted to do 
something different in each of the 30 cases, which would seem rare, 
but I do see your point.  

But I also see merit in having a generic interface; generic 
implementations can then be provided.  (Eg, SMTPThrowableHandler 
that mails the exception to someone).

The individual components could provide an adapter class that adapts
their specific interface to the generic interface, so I could quickly
install a handler that'd send me an email for each of the 30 cases.

-Paul

--
To unsubscribe, e-mail:   <mailto:commons-dev-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:commons-dev-help@jakarta.apache.org>


Mime
View raw message