I want to have a custom 500 error page. This can be done simply by creating a view in errors/500.blade.php
.
This is fine for production mode, but I no longer get the default exception/ debug pages when in debug mode (the one that looks grey and says "Whoops something went wrong").
Therefore, my question is: how can I have a custom 500 error page for production, but the original 500 error page when debug mode is true?
Simply add this code in \App\Exceptinons\Handler.php:
Or
Add this code to the
app/Exceptions/Handler.php
,render
method. I think this is clean and simple. Assuming you have custom 500 error page.use commented line when you need default whoops error page for debugging. use other one for custom 500 error page.
Add the code to the
app/Exceptions/Handler.php
file inside theHandler
class:The
convertExceptionToResponse
method gets right such errors that cause the 500 status.I found the best way to solve my problem is to add the following function to
App\Exceptions\Handler.php
Better solutions are welcome!