From 06aa12c930b51eb7075be01ed9406f26acfa3f0a Mon Sep 17 00:00:00 2001 From: Thomas Calvet Date: Fri, 12 Jan 2018 14:11:07 +0100 Subject: [PATCH] [Console] Keep the modified exception handler --- src/Symfony/Component/Console/Application.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/Symfony/Component/Console/Application.php b/src/Symfony/Component/Console/Application.php index be283aad16f38..eeb6a75bafded 100644 --- a/src/Symfony/Component/Console/Application.php +++ b/src/Symfony/Component/Console/Application.php @@ -166,7 +166,11 @@ public function run(InputInterface $input = null, OutputInterface $output = null if (!$phpHandler) { restore_exception_handler(); } elseif (!$debugHandler) { - $phpHandler[0]->setExceptionHandler(null); + $finalHandler = $phpHandler[0]->setExceptionHandler(null); + // if the Command changed the exception handler, keep it + if ($finalHandler !== $renderException) { + $phpHandler[0]->setExceptionHandler($finalHandler); + } } }