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.

Reply via email to