Hi,

Well, the HttpStatusCodeException is a usefull tool to provide an error
code to the client of the request and quickly abort request processing.
Otherwise more or less complicated code would have to be implemented to
terminate a request - esp. in the case of included requests - after the
sendError call.

Therefore, making it a RuntimeException (a SlingException that is) would
help have the exception pass through all the way up and have the Sling
main servlet do the sendError call and terminate the request.

I agree, that the HttpStatusCodeException is kind of weird. But because
IOExceptions are generally caught, logged and further ignored, the goal
of that exception would most probably almost never be met, if it would
be an IOException (or whatever checked Exception).

Of course, we could just as well drop that exception...

Regards
Felix

Am Samstag, den 29.12.2007, 12:06 -0800 schrieb Padraic Hannon:
> I agree with the points in your wiki post. One thing I didn't exactly  
> follow is what you want to do with the HttpStatusCodeException as that  
> seems to fit into the contingency camp of exceptions. I think you want  
> to make those extend IOException and thus not be a runtime exception?  
> I am unsure about the parent class, but I do agree that probably  
> should not be a Runtime exception since it is something that a program  
> would care about.
> 
> -paddy
> 
> On Dec 29, 2007, at 11:58 AM, Felix Meschberger wrote:
> 
> > Hi all,
> >
> > Prompted by a blog by Alexander Klimetschek [1] and a very interesting
> > paper on exceptions [2] I set back to think about the exceptions in  
> > the
> > Sling API and wrote a wiki page on this subject [3].
> >
> > To summarize, we should make the SlingException a RuntimeException and
> > all exceptions defined in the Sling API extend SlingException.  
> > Together
> > with appropriate catching inside Sling itself (letting  
> > RuntimeExceptions
> > pass through generally) this should help us streamline exception
> > handling.
> >
> > A prototype API definition may be found in the whiteboard at [4].
> >
> > What do you think ?
> >
> > Regards
> > Felix
> >
> > [1]
> > http://weblogs.goshaky.com/weblogs/alexkli/entry/exception_best_practices
> > [2] http://dev2dev.bea.com/pub/a/2006/11/effective-exceptions.html
> > [3] http://cwiki.apache.org/SLING/effective-exceptions.html
> > [4]
> > http://svn.apache.org/repos/asf/incubator/sling/whiteboard/fmeschbe/effective_exceptions
> 

Reply via email to