Web 服务的 zend 错误处理

发布于 2024-12-13 12:30:37 字数 311 浏览 2 评论 0原文

我有一个关于 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

青衫儰鉨ミ守葔 2024-12-20 12:30:37

对于使用 Zend_Application 的 ZF 应用程序,您应该确保您的 application.ini 文件中包含以下内容:

resources.frontController.throwExceptions = false

然后将捕获抛出的任何异常,并且 ErrorControllererrorAction() 方法将被调用。这为您提供了一个集中处理错误的地方。

For a ZF app that's using Zend_Application, you should ensure that your application.ini file has this in it:

resources.frontController.throwExceptions = false

Then any Exception that is thrown will be trapped and the ErrorController's errorAction() method will be called. This gives you a centralised place to handle errors.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文