Skip to content

Commit

Permalink
NullException when creating NetworkException (#403)
Browse files Browse the repository at this point in the history
* NullException when creating NetworkException

* Make sure we use the proper error handling

Co-authored-by: Nyholm <tobias.nyholm@gmail.com>
  • Loading branch information
thalassa-web and Nyholm committed Mar 7, 2020
1 parent 7044577 commit f4f233e
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions lib/Client/FileGetContents.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit f4f233e

Please sign in to comment.