How to Simulate 500 Error in Symfony 2

前端 未结 6 746
闹比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:14

    A good way to do it can be:

    use Symfony\Component\HttpKernel\Exception\HttpException;
    
    throw new HttpException(\Symfony\Component\HttpFoundation\Response::HTTP_INTERNAL_SERVER_ERROR, 'Testing the 500 error');
    

提交回复
热议问题