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
return new $app['route_class']();
};
$this['exception_handler'] = $this->share(function () {
return new ExceptionHandler();
$this['exception_handler'] = $this->share(function () use ($app) {
return new ExceptionHandler($app['debug']);
});
$this['dispatcher_class'] = 'Symfony\\Component\\EventDispatcher\\EventDispatcher';
......@@ -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, $errorEvent);
if ($errorEvent->hasResponse()) {
$event->setResponse($errorEvent->getResponse());
}
$this['dispatcher']->dispatch(SilexEvents::ERROR, $event);
}
/**
......
......@@ -22,10 +22,16 @@ use Symfony\Component\HttpKernel\Event\GetResponseForExceptionEvent;
*/
class ExceptionHandler implements EventSubscriberInterface
{
protected $debug;
public function __construct($debug)
{
$this->debug = $debug;
}
public function onSilexError(GetResponseForExceptionEvent $event)
{
$app = $event->getKernel();
$handler = new DebugExceptionHandler($app['debug']);
$handler = new DebugExceptionHandler($this->debug);
$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