Skip to content
This repository was archived by the owner on Mar 14, 2021. It is now read-only.

Catches exception when sending a request. #178

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion src/ApaiIO/Request/GuzzleRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
use ApaiIO\Configuration\ConfigurationInterface;
use ApaiIO\Operations\OperationInterface;
use GuzzleHttp\ClientInterface;
use GuzzleHttp\Exception\RequestException;
use GuzzleHttp\Psr7\Uri;

/**
Expand Down Expand Up @@ -72,7 +73,12 @@ public function perform(OperationInterface $operation, ConfigurationInterface $c
$request = new \GuzzleHttp\Psr7\Request('GET', $uri->withScheme($this->scheme), [
'User-Agent' => 'ApaiIO [' . ApaiIO::VERSION . ']'
]);
$result = $this->client->send($request);
try {
$result = $this->client->send($request);
}
catch (RequestException $e) {
return NULL;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

An exception is already throw in send method. You can try/catch runOperation method not ?

}

return $result->getBody()->getContents();
}
Expand Down