12
12
namespace Symfony \Component \HttpKernel \EventListener ;
13
13
14
14
use Psr \Log \LoggerInterface ;
15
- use Symfony \Component \Debug \ExceptionHandler ;
16
15
use Symfony \Component \Debug \Exception \FlattenException ;
17
16
use Symfony \Component \EventDispatcher \EventDispatcherInterface ;
18
17
use Symfony \Component \HttpFoundation \Request ;
19
- use Symfony \Component \HttpFoundation \Response ;
20
18
use Symfony \Component \HttpKernel \Event \FilterResponseEvent ;
21
19
use Symfony \Component \HttpKernel \Log \DebugLoggerInterface ;
22
20
use Symfony \Component \HttpKernel \Event \GetResponseForExceptionEvent ;
@@ -35,16 +33,12 @@ class ExceptionListener implements EventSubscriberInterface
35
33
protected $ controller ;
36
34
protected $ logger ;
37
35
protected $ debug ;
38
- private $ charset ;
39
- private $ fileLinkFormat ;
40
36
41
- public function __construct ($ controller , LoggerInterface $ logger = null , $ debug = false , $ charset = null , $ fileLinkFormat = null )
37
+ public function __construct ($ controller , LoggerInterface $ logger = null , $ debug = false )
42
38
{
43
39
$ this ->controller = $ controller ;
44
40
$ this ->logger = $ logger ;
45
41
$ this ->debug = $ debug ;
46
- $ this ->charset = $ charset ;
47
- $ this ->fileLinkFormat = $ fileLinkFormat ;
48
42
}
49
43
50
44
public function onKernelException (GetResponseForExceptionEvent $ event )
@@ -123,12 +117,8 @@ protected function logException(\Exception $exception, $message)
123
117
protected function duplicateRequest (\Exception $ exception , Request $ request )
124
118
{
125
119
$ attributes = array (
126
- 'exception ' => $ exception = FlattenException::create ($ exception ),
127
- '_controller ' => $ this ->controller ?: function () use ($ exception ) {
128
- $ handler = new ExceptionHandler ($ this ->debug , $ this ->charset , $ this ->fileLinkFormat );
129
-
130
- return new Response ($ handler ->getHtml ($ exception ), $ exception ->getStatusCode (), $ exception ->getHeaders ());
131
- },
120
+ '_controller ' => $ this ->controller ,
121
+ 'exception ' => FlattenException::create ($ exception ),
132
122
'logger ' => $ this ->logger instanceof DebugLoggerInterface ? $ this ->logger : null ,
133
123
);
134
124
$ request = $ request ->duplicate (null , null , $ attributes );
0 commit comments