From f4f233e88a3aa4bbf9c391f1d6973b364c83c59f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thalassa=20Ing=C3=A9nierie=20Web?= Date: Sat, 7 Mar 2020 14:32:37 +0100 Subject: [PATCH] NullException when creating NetworkException (#403) * NullException when creating NetworkException * Make sure we use the proper error handling Co-authored-by: Nyholm --- lib/Client/FileGetContents.php | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/lib/Client/FileGetContents.php b/lib/Client/FileGetContents.php index cdbe89f6..5e8e7b3b 100644 --- a/lib/Client/FileGetContents.php +++ b/lib/Client/FileGetContents.php @@ -22,9 +22,10 @@ public function sendRequest(RequestInterface $request, array $options = []): Res $content = file_get_contents($request->getUri()->__toString(), false, $context); error_reporting($level); if (false === $content) { - $error = error_get_last(); - - throw new NetworkException($request, $error['message']); + if ($error = error_get_last()) { + throw new NetworkException($request, $error['message']); + } + throw new NetworkException($request, 'Failed to get contents from '.$request->getUri()->__toString()); } $requestBuilder = new ResponseBuilder($this->responseFactory);