skip to Main Content

I’m working on a Symfony Bundle in order to add an AI recommandation when an Exception occurs, in the debug page (dev. mode).

To do that, I have followed the Symfony Documentation and created a custom controller to handle Exception.

This is a working example of the result :

enter image description here

However, this controller is not called when other exception occurs, such as PHP Syntax errors :

enter image description here

I’ve tried to create multiple listeners on different events (kernel.exception for example), but none of them is called when this type of Exception (PHP syntax) occurs.

Do you know how can I collect and handle ALL exceptions that occurs to a Symfony project ?

Thank you 🙂

2

Answers


  1. Chosen as BEST ANSWER

    following up :

    https://github.com/acseo/AIErrorExplainedBundle

    This Bundle proposes to override the default ErrorHandler (in dev mode) to add AI recommandation to solve the encountered error.

    it is in beta, feel free to install it, test it, and give me feedback about it 🙂


  2. Error pages for the production environment can be customized in different ways depending on your needs:

    1. If you only want to change the contents and styles of the error pages to match the rest of your application, override the default error templates;
    2. If you want to change the contents of non-HTML error output, create a new normalizer;
    3. If you also want to tweak the logic used by Symfony to generate error pages, override the default error controller;
    4. If you need total control of exception handling to run your own logic use the kernel.exception event.

    This is the default controller that you need to overwrite if you want to implement point 3.

    This is the sample code if you want to implement point 4

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search