Skip to content

Commit

Permalink
Merge pull request #80 from Holywings-ID/fix/guzzle_client_exception
Browse files Browse the repository at this point in the history
fix(guzzle_client): Replace caught exception
  • Loading branch information
stanleynguyen authored May 12, 2020
2 parents 36b25b5 + fdff120 commit a9c019c
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions src/HttpClient/GuzzleClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,7 @@
namespace Xendit\HttpClient;

use GuzzleHttp\Client as Guzzle;
use GuzzleHttp\Exception\ClientException;
use GuzzleHttp\Exception\ServerException;
use GuzzleHttp\Exception\RequestException;
use GuzzleHttp\RequestOptions;
use Xendit\Exceptions\ApiException;
use Xendit\Xendit;
Expand Down Expand Up @@ -96,7 +95,7 @@ public function sendRequest($method, string $url, array $defaultHeaders, $params

return [$rbody, $rcode, $rheader];
}

/**
* Execute request
*
Expand All @@ -112,7 +111,6 @@ private function _executeRequest(array $opts, string $url)
$params = $opts['params'];
$apiKey = Xendit::$apiKey;
$url = strval($url);

try {
if (count($params) > 0) {
$response = $this->http->request(
Expand All @@ -130,12 +128,12 @@ private function _executeRequest(array $opts, string $url)
]
);
}
} catch (ClientException | ServerException $e) {
} catch (RequestException $e) {
$response = $e->getResponse();
$rbody = json_decode($response->getBody()->getContents(), true);
$rcode = $response->getStatusCode();
$rheader = $response->getHeaders();

self::_handleAPIError(
array('body' => $rbody,
'code' => $rcode,
Expand Down

0 comments on commit a9c019c

Please sign in to comment.