Преглед изворни кода

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

Fabien Potencier пре 14 година
родитељ
комит
0b0356f348
1 измењених фајлова са 8 додато и 3 уклоњено
  1. 8 3
      src/Symfony/Component/HttpKernel/Debug/ExceptionHandler.php

+ 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)