You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Frederic Laub <in...@012.net.il> on 2002/10/07 09:11:26 UTC

[OT] Multinested exceptions class

Hi,

Sorry for polluting this newsgroup with this Java question on Exception
handling,
but I didn't succeed to implement the multi-nested exceptions class of
chapter 10
 of the Jakarta Struts Book Review:
http://www.theserverside.com/resources/strutsreview.jsp
and I thought I could borrow a few seconds from some Java Guru.

I have a main method that calls sequentially method A and than method B.
Method A and method B are throwing databaseException.
In the main method I want to process method B even if an exception is thrown
by method A.
The main method will throw an exception if errors occurred in method A
and/or method B,
the exception thrown by the main method will contain a collection of
exceptions.
I suppose the main method is a good candidate for this type of exception
handling?
In the main method:
 try {
  call method A
  } catch (DatabaseException e) {
   // LoadException extends BaseException which
   // has a Collection attribute, (among others) a method for adding an
exception
   // and one for retrieving the whole collections.
   LoadException loadException = new LoadException();
   loadException.addException(e);
   }
 try {
  call method B
  } catch (DatabaseException e) {
Question:  How do I add this DataBaseException to the previously created
loadException in method A?
   }
Question: Where do I put the code to read the collection of exceptions if
any?

An example or a link to a multi-nested exception example would be great!

Thank you for your time.
Frederic



--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>