-1

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 !

Pete_Gore
  • 594
  • 1
  • 5
  • 20

1 Answers1

0

I finally get it. There is not problem doing what I wanted to do. My issue came from a listener I forgot, listening on Doctrine postFlush method. When I tried to flush my Log entity, the listener was called, and ran another SQL query that also threw an exception.

As I already passed the kernel.exception event, this one wasn't caught, and the server just shew me a 500 page.

Everything works fine now.

Pete_Gore
  • 594
  • 1
  • 5
  • 20