I want intercept all errors of Symfony after that show them in JSON. In friendsofsymfony/rest-bundle v2 I can set parameters
fos_rest:
exception:
enabled: true
exception_controller: 'App\Controller\ExceptionController::showAction'
...
But in V3 the parameter exception_controller is deleted.
My current config of FOS REST:
fos_rest:
view:
formats:
xml: false
json: true
view_response_listener: force
serializer:
groups: ['Default']
serialize_null: true
format_listener:
rules:
- { path: ^/api/v1, priorities: [ json ], fallback_format: json, prefer_extension: true }
exception:
enabled: true
Official manual say that should use handlers in JMS. https://symfony.com/doc/current/bundles/FOSRestBundle/4-exception-controller-support.html But it does not contain explanation how config set in yaml.
You can intercept all errors by a symfony subscriber
services.yaml