Explorar o código

[HttpKernel] fixed exception handler when an exception is thrown during handling

Fabien Potencier %!s(int64=14) %!d(string=hai) anos
pai
achega
0b0356f348

+ 8 - 3
src/Symfony/Component/HttpKernel/Debug/ExceptionHandler.php

@@ -50,11 +50,16 @@ class ExceptionHandler
      */
     public function handle(\Exception $exception)
     {
-        $exception = FlattenException::create($exception);
+        try {
+            $exception = FlattenException::create($exception);
 
-        $response = new Response($this->decorate($exception, $this->getContent($exception)), 500);
+            $response = new Response($this->decorate($exception, $this->getContent($exception)), 500);
 
-        $response->send();
+            $response->send();
+        } catch (\Exception $e) {
+            // something nasty happened and we cannot throw an exception here anymore
+            printf('Exception thrown when handling an exception (%s: %s)', get_class($exception), $exception->getMessage());
+        }
     }
 
     private function getContent($exception)