java - Generally speaking, does a service need to throw exceptions to the Controller for handling?
我想大声告诉你
我想大声告诉你 2017-05-17 10:08:28
0
3
650
 我一般在项目里,业务层的方法报错都会直接往上抛到控制层来做统一的处理,一般来说,有经验的开发者会选择这样的异常处理方法吗?
如果不这样做,那么一般怎样做?
我想大声告诉你
我想大声告诉你

reply all(3)
Peter_Zhu

Why should we throw it into the control layer? Different field types will affect your business direction, so I usually unified convergence exceptions at the service layer.

刘奇

When there is a transaction, I will throw the exception to the control layer for processing, otherwise it may affect the rollback of the transaction

伊谢尔伦

Usually it is handled directly in the service

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!