How can I all errors show in json format in friendsofsymfony/rest-bundle v3

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: 'AppControllerExceptionController::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.

Source: Symfony Questions

Was this helpful?

0 / 0

Leave a Reply 0

Your email address will not be published. Required fields are marked *