2011-12-01 01:11
浏览 39

如何在PHP CodeIgniter中实现最后的错误处理?

In web frameworks I've built and used in the past, there's been some means to specify some form of "last resort" error handler. I'd appreciate any help in determining how to accomplish that goal using CodeIgniter, which is a legacy part of a product I'm working on.

The goal of the last resort error handler is to capture any exception that's bubbled up, unhandled, from the application logic. Since, at this high framework level, the handler can't resolve the exception, a typical implementation is to log the error (with associated context) and present a user-friendly error page rather than a scary, technical exception page.

I wasn't able to find support in the CodeIgniter documentation, but I expect there must be support for this. Did I not find support because I should use PHP's set_error_handler() and set_exception_handler()? (I'm new to PHP, but expert in Java, Ruby/Rails.)

Thanks in advance for you guidance!

图片转代码服务由CSDN问答提供 功能建议

在我过去构建和使用的Web框架中,有一些方法可以指定某种形式的“last” 度假村“错误处理程序 我很感激使用CodeIgniter确定如何实现这一目标的任何帮助,CodeIgniter是我正在研究的产品的遗留部分。

最后的错误处理程序的目标是 从应用程序逻辑中捕获任何未经处理的异常。 因为在这个高框架级别,处理程序无法解决异常,所以典型的实现是记录错误(带有相关联的上下文)并提供用户友好的错误页面而不是可怕的技术异常页面。

我无法在CodeIgniter文档中找到支持,但我希望必须得到支持。 我没有找到支持,因为我应该使用PHP的 set_error_handler() set_exception_handler()? (我是PHP的新手,但是Java,Ruby / Rails专家。)


  • 写回答
  • 好问题 提建议
  • 追加酬金
  • 关注问题
  • 收藏
  • 邀请回答

1条回答 默认 最新

  • dongyuji7309 2011-12-01 04:47

    It seems CodeIgniter 2.0+ registers the handlers you specified to load the CI_Exceptions class. I usually put a MY_Exceptions library in the application/libraries folder to "catch" them before CodeIgniter. I'd rather handle them gracefully than let CI show it's error pages.

    解决 无用
    打赏 举报

相关推荐 更多相似问题