From 3f03ae3f39f58595adb062582117376ea882d51d Mon Sep 17 00:00:00 2001 From: Tavo Nieves J Date: Tue, 10 Nov 2020 09:18:01 -0500 Subject: [PATCH] fix getProfile fail logic --- src/Codeception/Module/Symfony.php | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/Codeception/Module/Symfony.php b/src/Codeception/Module/Symfony.php index 37fb938a..a8f28bd0 100644 --- a/src/Codeception/Module/Symfony.php +++ b/src/Codeception/Module/Symfony.php @@ -619,6 +619,7 @@ public function runSymfonyConsoleCommand($command, $parameters = [], $consoleInp return $output; } + /** * @return \Symfony\Component\HttpKernel\Profiler\Profile */ @@ -630,11 +631,15 @@ protected function getProfile() } $profiler = $this->grabService('profiler'); - $response = $this->client->getResponse(); - if (null === $response) { - $this->fail("You must perform a request before using this method."); + try { + $response = $this->client->getResponse(); + return $profiler->loadProfileFromResponse($response); + } catch (\BadMethodCallException $e) { + $this->fail('You must perform a request before using this method.'); + } catch (\Exception $e) { + $this->fail($e->getMessage()); } - return $profiler->loadProfileFromResponse($response); + return null; } /**