diff --git a/src/Symfony/Bundle/TwigBundle/Controller/PreviewErrorController.php b/src/Symfony/Bundle/TwigBundle/Controller/PreviewErrorController.php
index 427e6996f8..70f3d99df4 100644
--- a/src/Symfony/Bundle/TwigBundle/Controller/PreviewErrorController.php
+++ b/src/Symfony/Bundle/TwigBundle/Controller/PreviewErrorController.php
@@ -35,7 +35,7 @@ class PreviewErrorController
public function previewErrorPageAction(Request $request, $code)
{
- $exception = FlattenException::create(new \Exception('Something has intentionally gone wrong.'), $code);
+ $exception = FlattenException::createFromThrowable(new \Exception('Something has intentionally gone wrong.'), $code);
/*
* This Request mimics the parameters set by
diff --git a/src/Symfony/Bundle/TwigBundle/Tests/Controller/ExceptionControllerTest.php b/src/Symfony/Bundle/TwigBundle/Tests/Controller/ExceptionControllerTest.php
index 9301fe37e5..1c32b6e2c5 100644
--- a/src/Symfony/Bundle/TwigBundle/Tests/Controller/ExceptionControllerTest.php
+++ b/src/Symfony/Bundle/TwigBundle/Tests/Controller/ExceptionControllerTest.php
@@ -26,7 +26,7 @@ class ExceptionControllerTest extends TestCase
$request = $this->createRequest('html');
$request->attributes->set('showException', false);
- $exception = FlattenException::create(new \Exception(), 404);
+ $exception = FlattenException::createFromThrowable(new \Exception(), 404);
$controller = new ExceptionController($twig, /* "showException" defaults to --> */ true);
$response = $controller->showAction($request, $exception, null);
@@ -40,7 +40,7 @@ class ExceptionControllerTest extends TestCase
$twig = $this->createTwigEnv(['@Twig/Exception/error.html.twig' => '']);
$request = $this->createRequest('txt');
- $exception = FlattenException::create(new \Exception());
+ $exception = FlattenException::createFromThrowable(new \Exception());
$controller = new ExceptionController($twig, false);
$controller->showAction($request, $exception);
@@ -54,7 +54,7 @@ class ExceptionControllerTest extends TestCase
$request = $this->createRequest('txt');
$request->attributes->set('showException', true);
- $exception = FlattenException::create(new \Exception());
+ $exception = FlattenException::createFromThrowable(new \Exception());
$controller = new ExceptionController($twig, false);
$controller->showAction($request, $exception);
@@ -67,7 +67,7 @@ class ExceptionControllerTest extends TestCase
$twig = $this->createTwigEnv(['@Twig/Exception/error.json.twig' => '{}']);
$request = $this->createRequest('json');
- $exception = FlattenException::create(new \Exception());
+ $exception = FlattenException::createFromThrowable(new \Exception());
$controller = new ExceptionController($twig, false);
$response = $controller->showAction($request, $exception);
diff --git a/src/Symfony/Component/Debug/Exception/FlattenException.php b/src/Symfony/Component/Debug/Exception/FlattenException.php
index 70ecd966e4..748e2c6011 100644
--- a/src/Symfony/Component/Debug/Exception/FlattenException.php
+++ b/src/Symfony/Component/Debug/Exception/FlattenException.php
@@ -20,4 +20,13 @@ use Symfony\Component\ErrorCatcher\Exception\FlattenException as BaseFlattenExce
*/
class FlattenException extends BaseFlattenException
{
+ /**
+ * @deprecated since Symfony 4.4, use Symfony\Component\ErrorHandler\Exception::createFromThrowable() instead.
+ */
+ public static function create(\Exception $exception, $statusCode = null, array $headers = []): self
+ {
+ @trigger_error(sprintf('The "%s()" method is deprecated since Symfony 4.4, use Symfony\Component\ErrorHandler\Exception::createFromThrowable() instead.', __METHOD__), E_USER_DEPRECATED);
+
+ return parent::createFromThrowable($exception, $statusCode, $headers);
+ }
}
diff --git a/src/Symfony/Component/ErrorCatcher/ErrorRenderer/ErrorRenderer.php b/src/Symfony/Component/ErrorCatcher/ErrorRenderer/ErrorRenderer.php
index 76b823fb41..bf2a1b1d51 100644
--- a/src/Symfony/Component/ErrorCatcher/ErrorRenderer/ErrorRenderer.php
+++ b/src/Symfony/Component/ErrorCatcher/ErrorRenderer/ErrorRenderer.php
@@ -49,7 +49,7 @@ class ErrorRenderer
/**
* Renders an Exception and returns the Response content.
*
- * @param \Exception|FlattenException $exception An \Exception or FlattenException instance
+ * @param \Throwable|FlattenException $exception A \Throwable or FlattenException instance
* @param string $format The request format (html, json, xml, etc.)
*
* @return string The Response content as a string
@@ -62,8 +62,8 @@ class ErrorRenderer
throw new ErrorRendererNotFoundException(sprintf('No error renderer found for format "%s".', $format));
}
- if (!$exception instanceof FlattenException) {
- $exception = FlattenException::create($exception);
+ if ($exception instanceof \Throwable) {
+ $exception = FlattenException::createFromThrowable($exception);
}
return $this->renderers[$format]->render($exception);
diff --git a/src/Symfony/Component/ErrorCatcher/ErrorRenderer/HtmlErrorRenderer.php b/src/Symfony/Component/ErrorCatcher/ErrorRenderer/HtmlErrorRenderer.php
index 43ca7dabd6..d73fc48b4a 100644
--- a/src/Symfony/Component/ErrorCatcher/ErrorRenderer/HtmlErrorRenderer.php
+++ b/src/Symfony/Component/ErrorCatcher/ErrorRenderer/HtmlErrorRenderer.php
@@ -150,7 +150,7 @@ EOF
} catch (\Exception $e) {
// something nasty happened and we cannot throw an exception anymore
if ($this->debug) {
- $e = FlattenException::create($e);
+ $e = FlattenException::createFromThrowable($e);
$exceptionMessage = sprintf('Exception thrown when handling an exception (%s: %s)', $e->getClass(), $this->escapeHtml($e->getMessage()));
} else {
$exceptionMessage = 'Whoops, looks like something went wrong.';
diff --git a/src/Symfony/Component/ErrorCatcher/Exception/FlattenException.php b/src/Symfony/Component/ErrorCatcher/Exception/FlattenException.php
index 27f7ace4be..5f6c81047f 100644
--- a/src/Symfony/Component/ErrorCatcher/Exception/FlattenException.php
+++ b/src/Symfony/Component/ErrorCatcher/Exception/FlattenException.php
@@ -36,11 +36,6 @@ class FlattenException
private $file;
private $line;
- public static function create(\Exception $exception, $statusCode = null, array $headers = [])
- {
- return static::createFromThrowable($exception, $statusCode, $headers);
- }
-
public static function createFromThrowable(\Throwable $exception, ?int $statusCode = null, array $headers = []): self
{
$e = new static();
diff --git a/src/Symfony/Component/ErrorCatcher/ExceptionHandler.php b/src/Symfony/Component/ErrorCatcher/ExceptionHandler.php
index 63b36d29d4..225db00622 100644
--- a/src/Symfony/Component/ErrorCatcher/ExceptionHandler.php
+++ b/src/Symfony/Component/ErrorCatcher/ExceptionHandler.php
@@ -156,12 +156,12 @@ class ExceptionHandler
* This method uses plain PHP functions like header() and echo to output
* the response.
*
- * @param \Exception|FlattenException $exception An \Exception or FlattenException instance
+ * @param \Throwable|FlattenException $exception A \Throwable or FlattenException instance
*/
public function sendPhpResponse($exception)
{
- if (!$exception instanceof FlattenException) {
- $exception = FlattenException::create($exception);
+ if ($exception instanceof \Throwable) {
+ $exception = FlattenException::createFromThrowable($exception);
}
if (!headers_sent()) {
diff --git a/src/Symfony/Component/ErrorCatcher/Tests/DependencyInjection/ErrorRendererTest.php b/src/Symfony/Component/ErrorCatcher/Tests/DependencyInjection/ErrorRendererTest.php
index 747cd50696..4fb7799d75 100644
--- a/src/Symfony/Component/ErrorCatcher/Tests/DependencyInjection/ErrorRendererTest.php
+++ b/src/Symfony/Component/ErrorCatcher/Tests/DependencyInjection/ErrorRendererTest.php
@@ -27,7 +27,7 @@ class ErrorRendererTest extends TestCase
$container = $this->getMockBuilder('Psr\Container\ContainerInterface')->getMock();
$container->expects($this->once())->method('has')->with('foo')->willReturn(false);
- $exception = FlattenException::create(new \Exception('Foo'));
+ $exception = FlattenException::createFromThrowable(new \Exception('Foo'));
(new ErrorRenderer($container))->render($exception, 'foo');
}
@@ -48,7 +48,7 @@ class ErrorRendererTest extends TestCase
$errorRenderer = new ErrorRenderer($container);
- $exception = FlattenException::create(new \RuntimeException('Foo'));
+ $exception = FlattenException::createFromThrowable(new \RuntimeException('Foo'));
$this->assertSame('Foo', $errorRenderer->render($exception, 'foo'));
}
}
diff --git a/src/Symfony/Component/ErrorCatcher/Tests/ErrorRenderer/ErrorRendererTest.php b/src/Symfony/Component/ErrorCatcher/Tests/ErrorRenderer/ErrorRendererTest.php
index 156de10c66..e839ceb1e2 100644
--- a/src/Symfony/Component/ErrorCatcher/Tests/ErrorRenderer/ErrorRendererTest.php
+++ b/src/Symfony/Component/ErrorCatcher/Tests/ErrorRenderer/ErrorRendererTest.php
@@ -24,7 +24,7 @@ class ErrorRendererTest extends TestCase
*/
public function testErrorRendererNotFound()
{
- $exception = FlattenException::create(new \Exception('foo'));
+ $exception = FlattenException::createFromThrowable(new \Exception('foo'));
(new ErrorRenderer([]))->render($exception, 'foo');
}
@@ -34,7 +34,7 @@ class ErrorRendererTest extends TestCase
*/
public function testInvalidErrorRenderer()
{
- $exception = FlattenException::create(new \Exception('foo'));
+ $exception = FlattenException::createFromThrowable(new \Exception('foo'));
(new ErrorRenderer([new \stdClass()]))->render($exception, 'foo');
}
@@ -43,7 +43,7 @@ class ErrorRendererTest extends TestCase
$renderers = [new FooErrorRenderer()];
$errorRenderer = new ErrorRenderer($renderers);
- $exception = FlattenException::create(new \RuntimeException('Foo'));
+ $exception = FlattenException::createFromThrowable(new \RuntimeException('Foo'));
$this->assertSame('Foo', $errorRenderer->render($exception, 'foo'));
}
}
diff --git a/src/Symfony/Component/ErrorCatcher/Tests/ErrorRenderer/HtmlErrorRendererTest.php b/src/Symfony/Component/ErrorCatcher/Tests/ErrorRenderer/HtmlErrorRendererTest.php
index 3054e28510..f211df072c 100644
--- a/src/Symfony/Component/ErrorCatcher/Tests/ErrorRenderer/HtmlErrorRendererTest.php
+++ b/src/Symfony/Component/ErrorCatcher/Tests/ErrorRenderer/HtmlErrorRendererTest.php
@@ -19,7 +19,7 @@ class HtmlErrorRendererTest extends TestCase
{
public function testRender()
{
- $exception = FlattenException::create(new \RuntimeException('Foo'));
+ $exception = FlattenException::createFromThrowable(new \RuntimeException('Foo'));
$expected = '%A%A
%AInternal Server Error%AFoo
%ARuntimeException%A';
$this->assertStringMatchesFormat($expected, (new HtmlErrorRenderer())->render($exception));
diff --git a/src/Symfony/Component/ErrorCatcher/Tests/ErrorRenderer/JsonErrorRendererTest.php b/src/Symfony/Component/ErrorCatcher/Tests/ErrorRenderer/JsonErrorRendererTest.php
index bbc754f909..a4782ee264 100644
--- a/src/Symfony/Component/ErrorCatcher/Tests/ErrorRenderer/JsonErrorRendererTest.php
+++ b/src/Symfony/Component/ErrorCatcher/Tests/ErrorRenderer/JsonErrorRendererTest.php
@@ -19,7 +19,7 @@ class JsonErrorRendererTest extends TestCase
{
public function testRender()
{
- $exception = FlattenException::create(new \RuntimeException('Foo'));
+ $exception = FlattenException::createFromThrowable(new \RuntimeException('Foo'));
$expected = '{"title":"Internal Server Error","status":500,"detail":"Foo","exceptions":[{"message":"Foo","class":"RuntimeException","trace":';
$this->assertStringStartsWith($expected, (new JsonErrorRenderer())->render($exception));
diff --git a/src/Symfony/Component/ErrorCatcher/Tests/ErrorRenderer/TxtErrorRendererTest.php b/src/Symfony/Component/ErrorCatcher/Tests/ErrorRenderer/TxtErrorRendererTest.php
index b3c817581c..8ee6ee3bf7 100644
--- a/src/Symfony/Component/ErrorCatcher/Tests/ErrorRenderer/TxtErrorRendererTest.php
+++ b/src/Symfony/Component/ErrorCatcher/Tests/ErrorRenderer/TxtErrorRendererTest.php
@@ -19,7 +19,7 @@ class TxtErrorRendererTest extends TestCase
{
public function testRender()
{
- $exception = FlattenException::create(new \RuntimeException('Foo'));
+ $exception = FlattenException::createFromThrowable(new \RuntimeException('Foo'));
$expected = '[title] Internal Server Error%A[status] 500%A[detail] Foo%A[1] RuntimeException: Foo%A';
$this->assertStringMatchesFormat($expected, (new TxtErrorRenderer())->render($exception));
diff --git a/src/Symfony/Component/ErrorCatcher/Tests/ErrorRenderer/XmlErrorRendererTest.php b/src/Symfony/Component/ErrorCatcher/Tests/ErrorRenderer/XmlErrorRendererTest.php
index f98e43920a..dc2bf25995 100644
--- a/src/Symfony/Component/ErrorCatcher/Tests/ErrorRenderer/XmlErrorRendererTest.php
+++ b/src/Symfony/Component/ErrorCatcher/Tests/ErrorRenderer/XmlErrorRendererTest.php
@@ -19,7 +19,7 @@ class XmlErrorRendererTest extends TestCase
{
public function testRender()
{
- $exception = FlattenException::create(new \RuntimeException('Foo'));
+ $exception = FlattenException::createFromThrowable(new \RuntimeException('Foo'));
$expected = '%A%AInternal Server Error%A500%AFoo%A';
$this->assertStringMatchesFormat($expected, (new XmlErrorRenderer())->render($exception));
diff --git a/src/Symfony/Component/ErrorCatcher/Tests/Exception/FlattenExceptionTest.php b/src/Symfony/Component/ErrorCatcher/Tests/Exception/FlattenExceptionTest.php
index c6d99662d2..3f8749578b 100644
--- a/src/Symfony/Component/ErrorCatcher/Tests/Exception/FlattenExceptionTest.php
+++ b/src/Symfony/Component/ErrorCatcher/Tests/Exception/FlattenExceptionTest.php
@@ -34,10 +34,10 @@ class FlattenExceptionTest extends TestCase
{
public function testStatusCode()
{
- $flattened = FlattenException::create(new \RuntimeException(), 403);
+ $flattened = FlattenException::createFromThrowable(new \RuntimeException(), 403);
$this->assertEquals('403', $flattened->getStatusCode());
- $flattened = FlattenException::create(new \RuntimeException());
+ $flattened = FlattenException::createFromThrowable(new \RuntimeException());
$this->assertEquals('500', $flattened->getStatusCode());
$flattened = FlattenException::createFromThrowable(new \DivisionByZeroError(), 403);
@@ -46,72 +46,72 @@ class FlattenExceptionTest extends TestCase
$flattened = FlattenException::createFromThrowable(new \DivisionByZeroError());
$this->assertEquals('500', $flattened->getStatusCode());
- $flattened = FlattenException::create(new NotFoundHttpException());
+ $flattened = FlattenException::createFromThrowable(new NotFoundHttpException());
$this->assertEquals('404', $flattened->getStatusCode());
- $flattened = FlattenException::create(new UnauthorizedHttpException('Basic realm="My Realm"'));
+ $flattened = FlattenException::createFromThrowable(new UnauthorizedHttpException('Basic realm="My Realm"'));
$this->assertEquals('401', $flattened->getStatusCode());
- $flattened = FlattenException::create(new BadRequestHttpException());
+ $flattened = FlattenException::createFromThrowable(new BadRequestHttpException());
$this->assertEquals('400', $flattened->getStatusCode());
- $flattened = FlattenException::create(new NotAcceptableHttpException());
+ $flattened = FlattenException::createFromThrowable(new NotAcceptableHttpException());
$this->assertEquals('406', $flattened->getStatusCode());
- $flattened = FlattenException::create(new ConflictHttpException());
+ $flattened = FlattenException::createFromThrowable(new ConflictHttpException());
$this->assertEquals('409', $flattened->getStatusCode());
- $flattened = FlattenException::create(new MethodNotAllowedHttpException(['POST']));
+ $flattened = FlattenException::createFromThrowable(new MethodNotAllowedHttpException(['POST']));
$this->assertEquals('405', $flattened->getStatusCode());
- $flattened = FlattenException::create(new AccessDeniedHttpException());
+ $flattened = FlattenException::createFromThrowable(new AccessDeniedHttpException());
$this->assertEquals('403', $flattened->getStatusCode());
- $flattened = FlattenException::create(new GoneHttpException());
+ $flattened = FlattenException::createFromThrowable(new GoneHttpException());
$this->assertEquals('410', $flattened->getStatusCode());
- $flattened = FlattenException::create(new LengthRequiredHttpException());
+ $flattened = FlattenException::createFromThrowable(new LengthRequiredHttpException());
$this->assertEquals('411', $flattened->getStatusCode());
- $flattened = FlattenException::create(new PreconditionFailedHttpException());
+ $flattened = FlattenException::createFromThrowable(new PreconditionFailedHttpException());
$this->assertEquals('412', $flattened->getStatusCode());
- $flattened = FlattenException::create(new PreconditionRequiredHttpException());
+ $flattened = FlattenException::createFromThrowable(new PreconditionRequiredHttpException());
$this->assertEquals('428', $flattened->getStatusCode());
- $flattened = FlattenException::create(new ServiceUnavailableHttpException());
+ $flattened = FlattenException::createFromThrowable(new ServiceUnavailableHttpException());
$this->assertEquals('503', $flattened->getStatusCode());
- $flattened = FlattenException::create(new TooManyRequestsHttpException());
+ $flattened = FlattenException::createFromThrowable(new TooManyRequestsHttpException());
$this->assertEquals('429', $flattened->getStatusCode());
- $flattened = FlattenException::create(new UnsupportedMediaTypeHttpException());
+ $flattened = FlattenException::createFromThrowable(new UnsupportedMediaTypeHttpException());
$this->assertEquals('415', $flattened->getStatusCode());
if (class_exists(SuspiciousOperationException::class)) {
- $flattened = FlattenException::create(new SuspiciousOperationException());
+ $flattened = FlattenException::createFromThrowable(new SuspiciousOperationException());
$this->assertEquals('400', $flattened->getStatusCode());
}
}
public function testHeadersForHttpException()
{
- $flattened = FlattenException::create(new MethodNotAllowedHttpException(['POST']));
+ $flattened = FlattenException::createFromThrowable(new MethodNotAllowedHttpException(['POST']));
$this->assertEquals(['Allow' => 'POST'], $flattened->getHeaders());
- $flattened = FlattenException::create(new UnauthorizedHttpException('Basic realm="My Realm"'));
+ $flattened = FlattenException::createFromThrowable(new UnauthorizedHttpException('Basic realm="My Realm"'));
$this->assertEquals(['WWW-Authenticate' => 'Basic realm="My Realm"'], $flattened->getHeaders());
- $flattened = FlattenException::create(new ServiceUnavailableHttpException('Fri, 31 Dec 1999 23:59:59 GMT'));
+ $flattened = FlattenException::createFromThrowable(new ServiceUnavailableHttpException('Fri, 31 Dec 1999 23:59:59 GMT'));
$this->assertEquals(['Retry-After' => 'Fri, 31 Dec 1999 23:59:59 GMT'], $flattened->getHeaders());
- $flattened = FlattenException::create(new ServiceUnavailableHttpException(120));
+ $flattened = FlattenException::createFromThrowable(new ServiceUnavailableHttpException(120));
$this->assertEquals(['Retry-After' => 120], $flattened->getHeaders());
- $flattened = FlattenException::create(new TooManyRequestsHttpException('Fri, 31 Dec 1999 23:59:59 GMT'));
+ $flattened = FlattenException::createFromThrowable(new TooManyRequestsHttpException('Fri, 31 Dec 1999 23:59:59 GMT'));
$this->assertEquals(['Retry-After' => 'Fri, 31 Dec 1999 23:59:59 GMT'], $flattened->getHeaders());
- $flattened = FlattenException::create(new TooManyRequestsHttpException(120));
+ $flattened = FlattenException::createFromThrowable(new TooManyRequestsHttpException(120));
$this->assertEquals(['Retry-After' => 120], $flattened->getHeaders());
}
@@ -133,7 +133,7 @@ class FlattenExceptionTest extends TestCase
public function testWrappedThrowable()
{
$exception = new FatalThrowableError(new \DivisionByZeroError('Ouch', 42));
- $flattened = FlattenException::create($exception);
+ $flattened = FlattenException::createFromThrowable($exception);
$this->assertSame('Ouch', $flattened->getMessage(), 'The message is copied from the original error.');
$this->assertSame(42, $flattened->getCode(), 'The code is copied from the original error.');
@@ -169,7 +169,7 @@ class FlattenExceptionTest extends TestCase
{
$exception = new \Exception('test', 123, new \ParseError('Oh noes!', 42));
- $flattened = FlattenException::create($exception)->getPrevious();
+ $flattened = FlattenException::createFromThrowable($exception)->getPrevious();
$this->assertEquals($flattened->getMessage(), 'Oh noes!', 'The message is copied from the original exception.');
$this->assertEquals($flattened->getCode(), 42, 'The code is copied from the original exception.');
@@ -223,7 +223,7 @@ class FlattenExceptionTest extends TestCase
$this->assertSame(
FlattenException::createFromThrowable($exception)->toArray(),
- FlattenException::create($exception)->toArray()
+ FlattenException::createFromThrowable($exception)->toArray()
);
}
@@ -262,7 +262,7 @@ class FlattenExceptionTest extends TestCase
NAN,
]);
- $flattened = FlattenException::create($exception);
+ $flattened = FlattenException::createFromThrowable($exception);
$trace = $flattened->getTrace();
$args = $trace[1]['args'];
$array = $args[0][1];
@@ -303,7 +303,7 @@ class FlattenExceptionTest extends TestCase
$a = ['foo', [2, &$a]];
$exception = $this->createException($a);
- $flattened = FlattenException::create($exception);
+ $flattened = FlattenException::createFromThrowable($exception);
$trace = $flattened->getTrace();
$this->assertContains('*DEEP NESTED ARRAY*', serialize($trace));
}
@@ -322,7 +322,7 @@ class FlattenExceptionTest extends TestCase
$a[21] = 'value1';
$exception = $this->createException($a);
- $flattened = FlattenException::create($exception);
+ $flattened = FlattenException::createFromThrowable($exception);
$trace = $flattened->getTrace();
$this->assertSame($trace[1]['args'][0], ['array', ['array', '*SKIPPED over 10000 entries*']]);
@@ -335,12 +335,12 @@ class FlattenExceptionTest extends TestCase
public function testAnonymousClass()
{
- $flattened = FlattenException::create(new class() extends \RuntimeException {
+ $flattened = FlattenException::createFromThrowable(new class() extends \RuntimeException {
});
$this->assertSame('RuntimeException@anonymous', $flattened->getClass());
- $flattened = FlattenException::create(new \Exception(sprintf('Class "%s" blah.', \get_class(new class() extends \RuntimeException {
+ $flattened = FlattenException::createFromThrowable(new \Exception(sprintf('Class "%s" blah.', \get_class(new class() extends \RuntimeException {
}))));
$this->assertSame('Class "RuntimeException@anonymous" blah.', $flattened->getMessage());
@@ -350,7 +350,7 @@ class FlattenExceptionTest extends TestCase
{
$exception = new \RuntimeException();
- $flattened = FlattenException::create($exception);
+ $flattened = FlattenException::createFromThrowable($exception);
$this->assertSame($exception->getTraceAsString(), $flattened->getTraceAsString());
$this->assertSame($exception->__toString(), $flattened->getAsString());
@@ -364,7 +364,7 @@ class FlattenExceptionTest extends TestCase
$exception = $test('foo123', 1, null, 1.5);
- $flattened = FlattenException::create($exception);
+ $flattened = FlattenException::createFromThrowable($exception);
$this->assertSame($exception->getTraceAsString(), $flattened->getTraceAsString());
$this->assertSame($exception->__toString(), $flattened->getAsString());
@@ -375,7 +375,7 @@ class FlattenExceptionTest extends TestCase
$exception = new \LogicException('This is message 1');
$exception = new \RuntimeException('This is messsage 2', 500, $exception);
- $flattened = FlattenException::create($exception);
+ $flattened = FlattenException::createFromThrowable($exception);
$this->assertSame($exception->getTraceAsString(), $flattened->getTraceAsString());
$this->assertSame($exception->__toString(), $flattened->getAsString());
diff --git a/src/Symfony/Component/HttpKernel/DataCollector/ExceptionDataCollector.php b/src/Symfony/Component/HttpKernel/DataCollector/ExceptionDataCollector.php
index 9d715b91c1..62c10a1347 100644
--- a/src/Symfony/Component/HttpKernel/DataCollector/ExceptionDataCollector.php
+++ b/src/Symfony/Component/HttpKernel/DataCollector/ExceptionDataCollector.php
@@ -29,7 +29,7 @@ class ExceptionDataCollector extends DataCollector
{
if (null !== $exception) {
$this->data = [
- 'exception' => FlattenException::create($exception),
+ 'exception' => FlattenException::createFromThrowable($exception),
];
}
}
diff --git a/src/Symfony/Component/HttpKernel/EventListener/ExceptionListener.php b/src/Symfony/Component/HttpKernel/EventListener/ExceptionListener.php
index 0d096252fb..833a0e3b6b 100644
--- a/src/Symfony/Component/HttpKernel/EventListener/ExceptionListener.php
+++ b/src/Symfony/Component/HttpKernel/EventListener/ExceptionListener.php
@@ -42,7 +42,7 @@ class ExceptionListener implements EventSubscriberInterface
public function logKernelException(GetResponseForExceptionEvent $event)
{
- $e = FlattenException::create($event->getException());
+ $e = FlattenException::createFromThrowable($event->getException());
$this->logException($event->getException(), sprintf('Uncaught PHP Exception %s: "%s" at %s line %s', $e->getClass(), $e->getMessage(), $e->getFile(), $e->getLine()));
}
@@ -64,7 +64,7 @@ class ExceptionListener implements EventSubscriberInterface
try {
$response = $event->getKernel()->handle($request, HttpKernelInterface::SUB_REQUEST, false);
} catch (\Exception $e) {
- $f = FlattenException::create($e);
+ $f = FlattenException::createFromThrowable($e);
$this->logException($e, sprintf('Exception thrown when handling an exception (%s: %s at %s line %s)', $f->getClass(), $f->getMessage(), $e->getFile(), $e->getLine()));
@@ -132,7 +132,7 @@ class ExceptionListener implements EventSubscriberInterface
{
$attributes = [
'_controller' => $this->controller,
- 'exception' => FlattenException::create($exception),
+ 'exception' => FlattenException::createFromThrowable($exception),
'logger' => $this->logger instanceof DebugLoggerInterface ? $this->logger : null,
];
$request = $request->duplicate(null, null, $attributes);
diff --git a/src/Symfony/Component/HttpKernel/Tests/DataCollector/ExceptionDataCollectorTest.php b/src/Symfony/Component/HttpKernel/Tests/DataCollector/ExceptionDataCollectorTest.php
index d7d45e1bdf..08e0ebb2d4 100644
--- a/src/Symfony/Component/HttpKernel/Tests/DataCollector/ExceptionDataCollectorTest.php
+++ b/src/Symfony/Component/HttpKernel/Tests/DataCollector/ExceptionDataCollectorTest.php
@@ -23,7 +23,7 @@ class ExceptionDataCollectorTest extends TestCase
{
$e = new \Exception('foo', 500);
$c = new ExceptionDataCollector();
- $flattened = FlattenException::create($e);
+ $flattened = FlattenException::createFromThrowable($e);
$trace = $flattened->getTrace();
$this->assertFalse($c->hasException());