On Nov 28, 2007, at 11:31 PM, Sumit Lohia wrote:

I have done something similar in my project but the exception hierarchy is unchecked. This allows me to use the same set of exceptions in my DAO code, and Controller code and not have to add 'throws RestletException' everywhere.

The entire point of checked exceptions is that you catch and deal with them. The problem with a lot of software is that programmers don't like dealing with errors because they're "a pain" or messy to deal with. Well, dealing with the real world is often messy.

Unchecked exceptions should be reserved for truly "exceptional," circumstances that can happen at any time.

Also, in this case, it's the Restlet framework that would have to catch them, not code you write (generally).

Also I can code against interfaces that know nothing about Restlets so don't have to add 'throws RestletException' even though the implementation might
throw a derived exception like NotFoundException.

RestletException could conceivably be derived from IOException. An interface that didn't anticipate that an implementation might need to do some kind of I/O as part of said implementation wasn't designed with sufficient foresight, IMHO.

I also have a StatusService that converts these exceptions to the appropriate HTTP error code and it works wonderfully.

That sounds like a good idea, however.

- Paul

Reply via email to