浏览代码

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