Skip to content

Commit fa61d16

Browse files
author
Robert Wittman
committed
Removed multiple json_decodes
1 parent 8a45c54 commit fa61d16

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

lib/Http/Client.php

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -130,9 +130,12 @@ public function request(Request $request)//$method, $url, $params = array(), $js
130130

131131
// Create our response objecct
132132
$response = new Response($res_body, $rcode, $rheaders);
133-
if(!is_null($response->getJsonBody()) && isset($response->getJsonBody()->errors))
133+
134+
// Check for Shopify Errors
135+
$jsonBody = $response->getJsonBody();
136+
if(!is_null($jsonBody) && isset($jsonBody->errors))
134137
{
135-
$errors = $response->getJsonBody()->errors;
138+
$errors = $jsonBody->errors;
136139
if(is_string($errors))
137140
{
138141
throw new Exception\ApiException($errors);
@@ -142,6 +145,9 @@ public function request(Request $request)//$method, $url, $params = array(), $js
142145
throw new Exception\ApiException(ucfirst($field).' '.$error);
143146
}
144147
}
148+
unset($jsonBody);
149+
150+
145151
$this->handleHttpCode($response->getHttpCode());
146152
return $response;
147153
}

0 commit comments

Comments
 (0)