Skip to content

Commit 57777f8

Browse files
committed
changes in guzzle exception
1 parent a514f14 commit 57777f8

File tree

1 file changed

+6
-7
lines changed

1 file changed

+6
-7
lines changed

src/Client.php

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -215,16 +215,15 @@ public function callGraphql($query)
215215
*/
216216
public function request($method,$url,array $options)
217217
{
218-
try
219-
{
218+
try {
220219
$client = new \GuzzleHttp\Client();
221220
return $client->request($method, $url, $options);
222221
}
223-
catch (RequestException $e)
224-
{
225-
$json_error = json_decode($e->getResponse()->getBody()->getContents(),true);
226-
if (isset($json_error['errors'])) {
227-
$error_message = \GuzzleHttp\json_encode($json_error);
222+
catch (RequestException $e) {
223+
$error_response = $e->getResponse()->getBody()->getContents();
224+
if(!empty($error_response)) {
225+
$json_error = json_decode($error_response,true);
226+
$error_message = isset($json_error['errors'])?json_encode($json_error['errors']):json_encode($json_error);
228227
}
229228
else {
230229
$error_message = $e->getMessage();

0 commit comments

Comments
 (0)