Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > Exception handling patterns/techniques

Reply
Thread Tools

Exception handling patterns/techniques

 
 
James L
Guest
Posts: n/a
 
      03-05-2008
How do you all feel about the commonly-seen technique of exception
wrapping? It can keep interfaces clean - but then you end up breaking
compile-time exception handling checking, as pointed out here:

http://weblogs.java.net/blog/bakksjo...exception.html

(and you risk never dealing with exceptions that are added to the code
later on...)

Also, suppose I have a class that contains ten methods, each of which do
something similar (e.g. comms) which can throw the same five exceptions
each time. Is there a handy pattern for refactoring those five catch
statements into one place, if such a thing were desirable?[1] (This is
maybe drifting into the area of aspect-oriented programming...)

One naive way might be to have each of the ten methods call a single
method with parameters, which contains a switch which calls the correct
ultimate target method - then you just have one try...catch wrapping
that switch statement. This is pretty ugly though.


[1] I realise that such a thing might very rarely be actually desirable!

thanks,
J
 
Reply With Quote
 
 
 
 
Mark Space
Guest
Posts: n/a
 
      03-05-2008
James L wrote:
> How do you all feel about the commonly-seen technique of exception
> wrapping? It can keep interfaces clean - but then you end up breaking
> compile-time exception handling checking, as pointed out here:


I've heard a rumor that Java 7 will contain some sort of official
support for wrapping exceptions. I'm kinda bummed about that, since I
don't think it will encourage clean code to be written, but I guess
market pressure is pushing Sun into it.

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
signal handling and (structured) exception handling Peter C++ 34 10-17-2009 10:03 AM
python list handling and Lisp list handling Mark Tarver Python 22 04-26-2009 09:36 PM
Exception of type 'System.Web.HttpUnhandledException' wasthrown.Exception has been thrown by the target of an invocation.System.WebSystem.Exception jobs ASP .Net 1 11-16-2007 05:57 PM
while executing my client program i get the exception javax.naming.LinkException: [Root exception is javax.naming.LinkException: [Root exception is javax.naming.NameNotFoundException: remaining if plz anybody know how to solve this problem then mahesh Java 0 03-08-2007 12:26 PM
SoapExtension for Global Exception handling; but prevent exception from propagating!! VSK ASP .Net Web Services 0 07-29-2003 05:39 PM



Advertisments