Follow-up on unanswered questions Custom ExceptionListener picks up 403 & 404, but not 500 errors and Symfony 2.4: Why are 500 errors not caught by kernel.exception listener.
I have implemented a custom exception listerner which works brilliantly for 403 and 404 errors, but does not catch 500 errors. Some feedback I have gotten indicates that some 500 errors occur before Symfony has a chance to run and therefor cannot be caught by any listeners.
What I have noticed is that no matter what type of strange error it is that I generate, whether it is a syntax error, undefined variable, unknown method, method call on a non-object, etc, it seems that ErrorHandler->handle() or ErrorHandler->handleFatalError() is always being called in the development environment (see some samples below) (While the same is not true for the development environment, where I often get a normal PHP error not inside Symfony).
What I am trying to do is that, whenever an error like this occurs in the production environment, I ALWAYS show a user friendly (Oops, something went wrong) error page and ALWAYS send an email with the error specifics. To me it seems that if I could customize ErrorHandler->handle(), then I would be able to accomplish this. The reason for this is simple, I want to be made aware of any errors that occur to my systems that are in production. One would think that this is a relatively common feature and yet I am unable to do it.
I am still learning Symfony and even though I have implemented custom console commands, custom authentication handlers more of the complex security features, I am really struggling with this. I would really appreciate if someone with some extensive Symfony experience could tell me if this is possible or not and, if so, how I would go about doing it.