How to Simulate 500 Error in Symfony 2

前端 未结 6 761
闹比i
闹比i 2021-02-07 00:25

I am wondering how would I simulate a 500 error in Symfony 2.

I have been reading this post where Raise suggests throwing an exception

6条回答
  •  长发绾君心
    2021-02-07 01:24

    If you want to trigger a FatalErrorException in Symfony2 to see if you app is handling it correctly, you can create an action like this in your controller:

    public function fatalErrorExceptionAction()
    {
        $unknown->getVoid();
    }
    

    The division by zero will generate a Warning while throwing the Exception, well, it'll just throw it. :-)

提交回复
热议问题