在我们的应用程序中,这些是使用的层:
Rest Service Endpoint Layer --> Business Layer --> DAO --> ORM
现在,每一层都适当地翻译其异常并将它们发送到下一层。例如,DAO Layer创建 aDaoException并 throws to Business Layer,Bussiness Layer将 this 转换为BusinessExceptionthrows 到RestService Layer由 cxf 映射器处理的位置(好吧,不是真的在 RestServiceLayer 中)。
我们已经把@Transactional方法放在了Business Layer。因此,如果在提交时发生异常,则exception只会在Rest Service Endpoint Layer. 现在,我必须在最顶层RollBackException etc.(Rest Service Endpoint Layer
处理这种情况的好方法是什么?我是否应该根本不翻译异常并仅在最顶层处理所有异常?