Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

symfony2 catch SQLSTATE Unknown database if host is down

I was just wandering how can we catch the error sent by Symfony when the database is down, due to a problem with the web host for exemple.

In exemple, it would allow me to redirect the user on a specific page if my database is not found .

Should i use try{}catch{} somwhere in the doctrine code to catch any error during the connection?

like image 791
goto Avatar asked Dec 31 '25 04:12

goto


1 Answers

You can create event listener for kernel.exception event which would get this exception and change the response for user.

like image 194
Alexey B. Avatar answered Jan 05 '26 21:01

Alexey B.



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!