Quantcast
Channel: Active questions tagged symfony4 - Stack Overflow
Viewing all articles
Browse latest Browse all 3924

Implement a custom error controller in Symfony 4.4

$
0
0

What i have done:

I have created this custom controller cause I want to pass to the error pages some extra variables.

#Controller/CustomErrorControler.phpnamespace App\Controller;use App\Controller\Base\BaseController;use Symfony\Component\ErrorHandler\Exception\FlattenException;use Symfony\Component\HttpKernel\Log\DebugLoggerInterface;class CustomErrorController extends BaseController{    public function show(FlattenException $exception, DebugLoggerInterface $logger = null)    {        return $this->getView('bundles/TwigBundle/Exception/error.html.twig', ["code" => $exception->getStatusCode(),"message" =>$exception->getStatusText()        ]);    }}

and the enabled

#config/packages/framework.yamlerror_controller: App\Controller\CustomErrorController::show

I have followed the documentation directly. My problem is that I need, for non-production stages to get the default exception templates provided by the framework.

I have tried to extend Symfony\Component\HttpKernel\Controller\ErrorController but I'm getting errors for autowiring.

Maybe I should use Symfony\Component\ErrorHandler\ErrorRenderer\ErrorRendererInterfaceAny ideas how to implement this?


Viewing all articles
Browse latest Browse all 3924

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>