Commit cb46028d authored by Fabien Potencier's avatar Fabien Potencier

removed deprecated method call in the exception handler

parent 9291f830
......@@ -12,7 +12,9 @@
namespace Silex;
use Symfony\Component\Debug\ExceptionHandler as DebugExceptionHandler;
use Symfony\Component\Debug\Exception\FlattenException;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpKernel\Event\GetResponseForExceptionEvent;
use Symfony\Component\HttpKernel\KernelEvents;
......@@ -48,7 +50,19 @@ class ExceptionHandler implements EventSubscriberInterface
$handler = new DebugExceptionHandler($this->debug);
$event->setResponse($handler->createResponse($event->getException()));
if (method_exists($handler, 'getHtml')) {
$exception = $event->getException();
if (!$exception instanceof FlattenException) {
$exception = FlattenException::create($exception);
}
$response = Response::create($handler->getHtml($exception), $exception->getStatusCode(), $exception->getHeaders())->setCharset(ini_get('default_charset'));
} else {
// BC with Symfony < 2.8
$response = $handler->createResponse($event->getException());
}
$event->setResponse($response);
}
/**
......
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