Thanks to visit codestin.com
Credit goes to github.com

Skip to content

[BUG][4.1] TwigBundle : Class "twig.controller.exception" does not exist #27438

Closed
@macintoshplus

Description

@macintoshplus

Symfony version(s) affected: 4.1.0

Description
After upgrade to Symfony 4.1.0, this error Class "twig.controller.exception" does not exist. is displayed when an exception is not catched by the user code.

How to reproduce

<?php

namespace App\Controller;

class FailController
{
    public function __invoke()
    {
        throw new \Exception("Error Processing Request", 1);
    }
}

Possible Solution

When I add this configuration, the exception handler work fine:

# config/packages/twig.yaml
twig:
    paths: ['%kernel.project_dir%/templates']
    debug: '%kernel.debug%'
    strict_variables: '%kernel.debug%'
    # I have add this line:
    exception_controller: Symfony\Bundle\TwigBundle\Controller\ExceptionController::showAction

And this service configuration

# config/services.yaml
services:

    Symfony\Bundle\TwigBundle\Controller\ExceptionController:
        alias: twig.controller.exception
        public: true

Additional context

The full error screenshot:
image

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions