Skip to content

Commit 446475f

Browse files
Fix debugging when TestFramework's GraphQl Client gets non-JSON response
1 parent 810cd3f commit 446475f

File tree

1 file changed

+6
-5
lines changed
  • dev/tests/api-functional/framework/Magento/TestFramework/TestCase/GraphQl

1 file changed

+6
-5
lines changed

dev/tests/api-functional/framework/Magento/TestFramework/TestCase/GraphQl/Client.php

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -111,20 +111,21 @@ public function get(string $query, array $variables = [], string $operationName
111111
*/
112112
private function processResponse(string $response, array $responseHeaders = [], array $responseCookies = [])
113113
{
114-
$responseArray = $this->json->jsonDecode($response);
115-
114+
$responseArray = null;
115+
try {
116+
$responseArray = $this->json->jsonDecode($response);
117+
} catch (\Exception $exception) {
118+
// Note: We don't care about this exception because we have error checking bellow if it fails to decode.
119+
}
116120
if (!is_array($responseArray)) {
117121
//phpcs:ignore Magento2.Exceptions.DirectThrow
118122
throw new \Exception('Unknown GraphQL response body: ' . $response);
119123
}
120-
121124
$this->processErrors($responseArray, $responseHeaders, $responseCookies);
122-
123125
if (!isset($responseArray['data'])) {
124126
//phpcs:ignore Magento2.Exceptions.DirectThrow
125127
throw new \Exception('Unknown GraphQL response body: ' . $response);
126128
}
127-
128129
return $responseArray['data'];
129130
}
130131

0 commit comments

Comments
 (0)