Web 服务的 zend 错误处理
我有一个关于 Zend 中错误处理的问题。我对 zend 框架相当陌生。
我是我正在从事的这个项目的新手,以前的开发人员没有处理服务错误,而且应用程序相当大,所以我试图找出一种简单的方法来处理服务返回的所有错误,甚至处理服务失败时出现错误。 因此,当出现错误时,我们需要提醒用户出现问题并显示错误。
现在,由于我将在模型中得到它,我如何以优雅的方式处理它,这样就不需要做太多返工。
我可以创建一个公共类并扩展它吗?如果出现任何错误,我还需要提醒用户。 我想要一种更好的方法,因为我有超过 150 个控制器文件和大约 100 多个模型文件。
谢谢
I have a question regarding error handling in Zend. I am fairly new to zend frame work.
I am new on this project that i am working on and the previous developers didn't handle service errors and the application is fairly large so I am trying to figure out an easy way to handle all the errors the service returns, and even handle the errors when service fails.
so when ever there is an error we need to alert the user that something is wrong and show the error.
now since i will be getting that in Model, how do I handle this in elegant way so that there is not much rework to be done.
Can i create a common class and extend it? I also need to alert the user in case of any error.
I want a better way because I have more than 150 controller files and about more than 100 model files.
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
对于使用
Zend_Application
的 ZF 应用程序,您应该确保您的application.ini
文件中包含以下内容:然后将捕获抛出的任何异常,并且
ErrorController
的errorAction()
方法将被调用。这为您提供了一个集中处理错误的地方。For a ZF app that's using
Zend_Application
, you should ensure that yourapplication.ini
file has this in it:Then any Exception that is thrown will be trapped and the
ErrorController
'serrorAction()
method will be called. This gives you a centralised place to handle errors.