Examples of this you may see in the microsling DefaultSlingServlet and StreamServlet.....
The DefaultSlingServlet has to catch and threat the ServletException and IOException separately just to be able to handle the Exception declared by SlingRequestContext. Regards Felix Am Freitag, den 19.10.2007, 15:37 +0200 schrieb Carsten Ziegeler: > Felix Meschberger wrote: > > > > Another point is, that whenever a method is declared throws Exception I > > am force to catch(Exception), which is something a definitely do not > > like because I might want to let RuntimeException pass through. > > Otherwise I would also be required to declare throws Exception and may > > not even be able to describe what exact exception I am expected to > > throw ... > > > While I usually tend to just throw Exception (as Bertrand does), this > usually creates nasty code for clients of the api. Imagine you implement > an interface from another api which has a method that declares to throw > exception A and B. Now in the implementation of the method you call the > ms api (ms = microsling :) ) which throws exception. So you have to test > if the ms api call throws exception A or B and pass this through or if > it is any other exception, you have to wrap it. > If the ms api just throws sling exception you catch it, wrap it and > that's it. > > Carsten >
