Search code examples
symfonyfosrestbundlesymfony-3.4

Symfony (3.4.2) - Error: Controller "fos_rest.exception.twig_controller" cannot be fetched from the container because it is private


I'm on an api project using FOSRestBundle on Symfony 3.4 and have some error when I want to use my own error messages. It says me:

Controller "fos_rest.exception.twig_controller" cannot be fetched from the container because it is private. Did you forget to tag the service with "controller.service_arguments"

I'm stuck on this error, I think a config is missing but I don't understand which one...

Thanks


Solution

  • I found the solution: Add to your config.yml, in fos_rest:

    fos_rest:
        //
        exception:
            //
            exception_controller: 'fos_rest.exception.controller:showAction'