Symfony2 FOS Rest错误页,仅在调试中显示

Symfony2 FOS Rest错误页,仅在调试中显示,symfony,fosrestbundle,Symfony,Fosrestbundle,我遇到的问题是,我在fos_rest中配置的所有错误页面仅在调试模式下工作 FOS\RestBundle\Controller\ExceptionController 只有在启用调试时,异常控制器才能从中正确查找自定义细枝错误页。 然而,当我禁用调试模式时,我得到了一个抛出的异常 Twig抱怨说它是404,尽管它已经知道它被映射了 我的配置: fos_rest: disable_csrf_role: ROLE_USER routing_loader: defa

我遇到的问题是,我在fos_rest中配置的所有错误页面仅在调试模式下工作

FOS\RestBundle\Controller\ExceptionController 
只有在启用调试时,异常控制器才能从中正确查找自定义细枝错误页。 然而,当我禁用调试模式时,我得到了一个抛出的异常 Twig抱怨说它是404,尽管它已经知道它被映射了

我的配置:

fos_rest:
    disable_csrf_role: ROLE_USER
    routing_loader:
        default_format: json
        include_format: false
    service:
        exception_handler:    fos_rest.view.exception_wrapper_handler
    exception:
        enabled: true
        codes:
            'Symfony\Component\Routing\Exception\ResourceNotFoundException': 404
            'Symfony\Component\HttpKernel\Exception\NotFoundHttpException': 404
            'Symfony\Component\Routing\Exception\ResourceNotFoundException': 404
            'Symfony\Component\Security\Core\Exception\AccessDeniedException': 403
            'Symfony\Component\Security\Core\Exception\DisabledException': 403
            'Doctrine\DBAL\Exception\ServerException': 500
        codes:
        messages:
            'Symfony\Component\Translation\Exception\NotFoundResourceException': false
            'Symfony\Component\Security\Core\Exception\AccessDeniedException': true
            'Symfony\Component\Security\Core\Exception\DisabledException': true
            'Doctrine\DBAL\Exception\ServerException': false
    body_listener: true
    view:
        view_response_listener: true
        formats:
            json: true
            xml: false
            html: true
        templating_formats:
            json: false
            xml: false
            html: true
        force_redirects:
            html: true
        failed_validation: HTTP_BAD_REQUEST
        default_engine: twig
    format_listener:
        rules:
            - priorities: [json, html]
            - fallback_format: json
            - { path: '^/css', priorities: [ 'text/css', '*/*'], fallback_format: css, prefer_extension: true }                        
            - { path: '^/api', priorities: [ 'json', 'text/html'], fallback_format: json, prefer_extension: false }
            - { path: '^/', priorities: [ 'text/html', '*/*'], fallback_format: json, prefer_extension: false }