+1
Craig L Russell wrote:
Hi,
It's not obvious to me that we should be catching NPE and wrapping
them. I wasn't part of the original design, but it seems that
catching NPE would tend to hide the actual source of the problem, and
it would be better to have the highest level code that knew enough to
catch Exception actually do this.
OOTH, I believe that catching SQLException, JPAException, and
JDOException and wrapping them in RollerException does make sense.
Craig
On Oct 10, 2006, at 1:34 PM, Mitesh Meswani wrote:
Hi Markus,
I think it should be enough to make sure that persistence related
exceptions are caught and rethrown as RollerException as you have
shown in your example below.
Do you think catching all RuntimeExcpetion, like SQLExceptions or
NullPointerExceptions (which most probably should be due to bugs in
the persistence provider's code) and rethrowing them as (checked)
RollerExceotion would add any value?
Thanks,
Mitesh
Markus Fuchs wrote:
Thank you!
Mitesh, Craig,
Shall catch all RuntimeExceptions then and re-throw them as
RollerExceptions?
-- markus.
Allen Gilliland wrote:
Markus,
I don't think there is really a perfect answer to your question,
but I think that in general any exceptions that are specific to
the persistence implementation should be caught and rethrown as a
RollerException. Whether or not to catch RuntimeExceptions could
probably be debated, but I think in general it's preferable to
catch them and rethrow as a normal RollerException.
-- Allen
Markus Fuchs wrote:
Hi all,
I'm helping Mitesh implementing the persistence layer abstraction
for roller.
I'm wondering, if strategy specific exceptions should be wrapped
into
RollerExceptions by the strategy implementation. All persistence
layers throw RuntimeExceptions: PersistenceExceptions for JPA,
JDOExceptions for JDO or HibernateExceptions for Hibernate.
Should strategy specific RuntimeExceptions be wrapped into checked
RollerExceptions? E.g. in JPAPersistenceStrategy, we could implement
something like:
public void flush() throws RollerException {
try {
EntityManager em = getEntityManager(false);
if (isTransactionActive(em)) {
em.getTransaction().commit();
}
em.close();
} catch (PersistenceException e) {
throw new RollerException(e);
}
}
Also, should be same be done for other persistence layer related
exceptions?
E.g. SQLExceptions or NullPointerExceptions?
Thanks,
-- markus.
Craig Russell
Architect, Sun Java Enterprise System http://java.sun.com/products/jdo
408 276-5638 mailto:[EMAIL PROTECTED]
P.S. A good JDO? O, Gasp!