Skip to content

Commit f4f233e

Browse files
thalassa-webNyholm
andauthored
NullException when creating NetworkException (#403)
* NullException when creating NetworkException * Make sure we use the proper error handling Co-authored-by: Nyholm <[email protected]>
1 parent 7044577 commit f4f233e

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

Diff for: lib/Client/FileGetContents.php

+4-3
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,10 @@ public function sendRequest(RequestInterface $request, array $options = []): Res
2222
$content = file_get_contents($request->getUri()->__toString(), false, $context);
2323
error_reporting($level);
2424
if (false === $content) {
25-
$error = error_get_last();
26-
27-
throw new NetworkException($request, $error['message']);
25+
if ($error = error_get_last()) {
26+
throw new NetworkException($request, $error['message']);
27+
}
28+
throw new NetworkException($request, 'Failed to get contents from '.$request->getUri()->__toString());
2829
}
2930

3031
$requestBuilder = new ResponseBuilder($this->responseFactory);

0 commit comments

Comments
 (0)