incubator-jspwiki-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Andrew Jaquith <>
Subject Re: error handling Was: author ids
Date Sun, 24 Aug 2008 17:42:53 GMT
The short answer: +1

The longer answer:

Yeah, I do think we should throw more checked Exceptions... the NPEs  
(unchecked) are always a pain in the butt to debug.  
IllegalStateExceptions are a little easier to deal with, because they  
generally supply a good stack trace and error message.

That said, I don't think we should be overly aggressive about wrapping  
caught Exceptions in WikiException, because it tends to dilute to root  
cause, which might be more usefully dealt with upstream. For example,  
any of the Exceptions generated by core classes (and propagated  
upwards to the presentation tier) should be as specific as practical  
so we can redirect users gracefully.

Not to beat the Stripes drum too much, but it has a neat  
ExceptionHandler class that is, in essence, a super-duper "exception  
catcher" that can return different Resolutions (for example) depending  
on the class of exception. Right now the subclass I've created  
(WikiExceptionHandler) doesn't do anything but forward/redirect to  
Error.jsp. But it could do a lot more. Being as specific as possible  
would help.

So, I think we should:
- Discourage returning nulls in favor of checked Exceptions (where  
- Return specific Exceptions rather than the generic WikiException  
(where practical)


On Aug 24, 2008, at 12:44 PM, Janne Jalkanen wrote:

>> Had a few minutes to myself this morning, so I committed the  
>> changes to UserProfile/UserDatabase classes. Uids are now Strings.
> Looks good :-)
> This reminds me of another thing:
> JCR prefers throwing a wild array of Exceptions to describe any  
> anomalic situation.  JSPWiki has so far been pretty light on these,  
> with most accessor methods like WikiPage.getLastModified() returning  
> a null in case of a problem.
> What is the general feeling on this, should 3.0 propagate exceptions  
> upwards (possibly wrapping them inside WikiExceptions), or catch  
> them early?  Throwing the exceptions makes the coder's life a bit  
> more tenous because they have to be caught and examined, but on the  
> other hand, they do make the code more robust (and protect against  
> hazy NullPointerExceptions).
> /Janne

View raw message