It's considered good practice to have an exception for each layer of application (i.e. PresentationException
, ServiceException
, PersistenceException
etc). But what if my service-layer directly calls DAO methods (methods of persistence layer) without additional operations.
Like this:
public class MyService {
private IPersonDAO dao = new PersonDAO();
public void deletePerson(int id) {
dao.deletePerson(id);
}
}
Should I wrap this DAO method invocation with a try-catch
block and rethrow possible exceptions as ServiceException
? Should each DAO method throw only PersistenceException
?