diff --git a/Handler/AbstractExceptionHandler.php b/Handler/AbstractExceptionHandler.php index e070bab..6e4db7d 100644 --- a/Handler/AbstractExceptionHandler.php +++ b/Handler/AbstractExceptionHandler.php @@ -113,7 +113,8 @@ public function onKernelException(ExceptionEvent $event) $backtrace->setFileContent($this->buildBacktrace($event)); // Unset the used session variable - $session = $event->getRequest()->getSession(); + $request = $event->getRequest(); + $session = $request->hasSession() ? $request->getSession() : null; if ($session) { $session->remove(self::SESSION_FILENAME); $session->set(self::SESSION_ERROR, $exception->getMessage()); @@ -204,7 +205,7 @@ public function onKernelResponse(ResponseEvent $responseObject) $response = $responseObject->getResponse(); $request = $responseObject->getRequest(); $statusCode = $response->getStatusCode(); - $session = $request->getSession(); + $session = $request->hasSession() ? $request->getSession() : null; if (!$this->configuration->isProductionEnvironment()) { // no production! -> don't sent an email