dongnanke4106 2014-03-19 10:03
浏览 74
已采纳

错误500页 - 如何获取最后一个异常?

If an exception has been thrown, Symfony 1.4 shows by default the "Oops! An Error Occurred" page. I defined an own page (http://symfony-check.org/permalink/customize-the-oops-an-error-occurred-page) and want to inform me by mail if this happens. So is there any chance to get the thrown exception? Something like error_get_last() ?

  • 写回答

1条回答 默认 最新

  • doutonghang2761 2014-03-20 10:42
    关注

    Thanks for the suggestion @waldek_c!

    Finally I solved the problem with a filter and catch the Exception before the forward to the errorpage. Like this: http://blog.felixdv.com/2008/01/28/exception-catcher-filter-for-symfony/

    This is my Filter:

    class errorHandlingFilter extends sfFilter
    {
    public function execute($filterChain)
    {
        try
        {
            $filterChain->execute();
        }
        catch(Exception $e)
        {
            if($e instanceof sfStopException || $e instanceof sfError404Exception) // common symfony exceptions that are allowed
            {
                throw $e;
            }
            else
            {
                // do errorhandling here
                throw $e;
            }
        }
    }
    }
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 我想咨询一下路面纹理三维点云数据处理的一些问题,上传的坐标文件里是怎么对无序点进行编号的,以及xy坐标在处理的时候是进行整体模型分片处理的吗
  • ¥15 CSAPPattacklab
  • ¥15 一直显示正在等待HID—ISP
  • ¥15 Python turtle 画图
  • ¥15 关于大棚监测的pcb板设计
  • ¥15 stm32开发clion时遇到的编译问题
  • ¥15 lna设计 源简并电感型共源放大器
  • ¥15 如何用Labview在myRIO上做LCD显示?(语言-开发语言)
  • ¥15 Vue3地图和异步函数使用
  • ¥15 C++ yoloV5改写遇到的问题