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; } /**