what i am trying to do is if the connection to the database fails, instead of getting No connection could be made because the target machine actively refused it
, i want to throw a custom view that displays a simple h1 with the text that the connection fails. How can i do that?
3
Answers
The answer was given at the top, but i made it work with some modifications.
You can do this by modifying your
app/Exceptions/Handler.php
to catch that specific error:Of course you can change the
QueryException
to any exception that you want to handle, such as:IlluminateDatabaseEloquentModelNotFoundException
or any other.In
app/Exceptions/Handler.php
In
resources/views/errors
,errors.database
, you can create custom style