Persist entity after catching Doctrine exception

I’m trying to create a log system on my website running Symfony 4.
Everytime an exception is thrown, I catch it into a listener, and then create a Log entity containing the exception values and also send it to me by email.

But the fact is when the exception is a Doctrine PDO Exception, the flush seems to crash the app.
I mean, the flush actually works but all the code after is is not executed (mail not sent, redirection not working, …).

If I comment the flush, everything works fine (except that I don’t get my entity persisted of course).

I tried to clear() the EntityManagerInterface ; to create a new one ; nothing works.

Any idea ?

Thanks !

Source: Symfony4 Questions

Was this helpful?

0 / 0

Leave a Reply 0

Your email address will not be published. Required fields are marked *