Commit 52a2fdaf authored by Fabien Potencier's avatar Fabien Potencier

removed the wrapping of the event for the exception event

It is indeed a good thing to do but for consistency, it must be done for
all events. As this is not possible now, I prefer to revert it for now.
parent dd39fd36
...@@ -81,8 +81,8 @@ class Application extends \Pimple implements HttpKernelInterface, EventSubscribe ...@@ -81,8 +81,8 @@ class Application extends \Pimple implements HttpKernelInterface, EventSubscribe
return new $app['route_class'](); return new $app['route_class']();
}; };
$this['exception_handler'] = $this->share(function () { $this['exception_handler'] = $this->share(function () use ($app) {
return new ExceptionHandler(); return new ExceptionHandler($app['debug']);
}); });
$this['dispatcher_class'] = 'Symfony\\Component\\EventDispatcher\\EventDispatcher'; $this['dispatcher_class'] = 'Symfony\\Component\\EventDispatcher\\EventDispatcher';
...@@ -638,12 +638,7 @@ class Application extends \Pimple implements HttpKernelInterface, EventSubscribe ...@@ -638,12 +638,7 @@ class Application extends \Pimple implements HttpKernelInterface, EventSubscribe
} }
} }
$errorEvent = new GetResponseForExceptionEvent($this, $event->getRequest(), $event->getRequestType(), $event->getException()); $this['dispatcher']->dispatch(SilexEvents::ERROR, $event);
$this['dispatcher']->dispatch(SilexEvents::ERROR, $errorEvent);
if ($errorEvent->hasResponse()) {
$event->setResponse($errorEvent->getResponse());
}
} }
/** /**
......
...@@ -22,10 +22,16 @@ use Symfony\Component\HttpKernel\Event\GetResponseForExceptionEvent; ...@@ -22,10 +22,16 @@ use Symfony\Component\HttpKernel\Event\GetResponseForExceptionEvent;
*/ */
class ExceptionHandler implements EventSubscriberInterface class ExceptionHandler implements EventSubscriberInterface
{ {
protected $debug;
public function __construct($debug)
{
$this->debug = $debug;
}
public function onSilexError(GetResponseForExceptionEvent $event) public function onSilexError(GetResponseForExceptionEvent $event)
{ {
$app = $event->getKernel(); $handler = new DebugExceptionHandler($this->debug);
$handler = new DebugExceptionHandler($app['debug']);
$event->setResponse($handler->createResponse($event->getException())); $event->setResponse($handler->createResponse($event->getException()));
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment