Home  >  Article  >  Backend Development  >  MVC的MODEL层是不是不可以抛出异常??

MVC的MODEL层是不是不可以抛出异常??

WBOY
WBOYOriginal
2016-06-23 14:39:001151browse

有人对我说 " 针对于mvc的设计 model层不应该进行任何的抛错等操作。这些操作应该由c来完成。"

是这样的吗? M层为什么不能抛出异常? 我无法理解


回复讨论(解决方案)

这并没有一定的规则

但他说的也有些道理,model 是业务逻辑,如果 model 也有异常的话,那整个流程都是错误的了
当然他说的是:当 model 出现异常的时候,只抛出,不处理。处理交给 Controller

控制层调用model业务逻辑返回值,做相应的抛出异常。

这话太绝对了。这种东西没有标准。M 层也可以抛出异常。


Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn