diff --git a/composer.json b/composer.json index de78f50..da2b127 100644 --- a/composer.json +++ b/composer.json @@ -3,7 +3,7 @@ "description": "Symfony errors Catcher module for Hawk.so", "keywords": ["hawk", "php", "error", "catcher", "monolog", "symfony"], "type": "library", - "version": "0.0.3", + "version": "0.0.4", "license": "MIT", "require": { "php": "^7.2 || ^8.0", diff --git a/src/Monolog/Handler.php b/src/Monolog/Handler.php index b9f531f..80e22d0 100644 --- a/src/Monolog/Handler.php +++ b/src/Monolog/Handler.php @@ -45,6 +45,12 @@ public function doWrite($record): void private function collectRequestInfo(): array { + $currentRequest = $this->request->getCurrentRequest(); + + if ($currentRequest === null) { + return []; + } + $factory = new PsrHttpFactory( Psr17FactoryDiscovery::findServerRequestFactory(), Psr17FactoryDiscovery::findStreamFactory(), @@ -52,9 +58,7 @@ private function collectRequestInfo(): array Psr17FactoryDiscovery::findResponseFactory() ); - $request = $factory->createRequest( - $this->request->getCurrentRequest() - ); + $request = $factory->createRequest($currentRequest); return [ 'method' => $request->getMethod(),