From d841282d956b521c22008a2073bfb82a10811254 Mon Sep 17 00:00:00 2001 From: Deng Zhi Cheng Date: Fri, 13 Mar 2020 15:51:56 +0800 Subject: [PATCH] Change ExceptionListener to ErrorListener --- create_framework/http_kernel_httpkernel_class.rst | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/create_framework/http_kernel_httpkernel_class.rst b/create_framework/http_kernel_httpkernel_class.rst index 96bda4df692..1cf76830abd 100644 --- a/create_framework/http_kernel_httpkernel_class.rst +++ b/create_framework/http_kernel_httpkernel_class.rst @@ -66,7 +66,7 @@ framework: it matches the incoming request and populates the request attributes with route parameters. Our code is now much more concise and surprisingly more robust and more -powerful than ever. For instance, use the built-in ``ExceptionListener`` to +powerful than ever. For instance, use the built-in ``ErrorListener`` to make your error management configurable:: $errorHandler = function (Symfony\Component\ErrorHandler\Exception\FlattenException $exception) { @@ -74,14 +74,14 @@ make your error management configurable:: return new Response($msg, $exception->getStatusCode()); }; - $dispatcher->addSubscriber(new HttpKernel\EventListener\ExceptionListener($errorHandler)); + $dispatcher->addSubscriber(new HttpKernel\EventListener\ErrorListener($errorHandler)); -``ExceptionListener`` gives you a ``FlattenException`` instance instead of the +``ErrorListener`` gives you a ``FlattenException`` instance instead of the thrown ``Exception`` or ``Error`` instance to ease exception manipulation and display. It can take any valid controller as an exception handler, so you can create an ErrorController class instead of using a Closure:: - $listener = new HttpKernel\EventListener\ExceptionListener( + $listener = new HttpKernel\EventListener\ErrorListener( 'Calendar\Controller\ErrorController::exception' ); $dispatcher->addSubscriber($listener);