I published Laravel’s error pages and customized them. I can test a 404 error, for example, but if I throw an Exception in my controller to test the 500 error page, the debug page of Laravel is displayed instead of my custom 500 error page. How can I test the 500 error page my users will actually see?
2
Answers
Instead of throwing an Exception in your controller, just call
abort(500)
. This will display your custom 500 page.You can set
APP_DEBUG=false
in the .env file and when the program encounters an error, it will display the 500 page.