Skip to content

Commit 587ff13

Browse files
committed
chore: better guzzle docs in ApiException
Co-authored-by: Brent Shaffer <betterbrent@google.com>
1 parent ea23f87 commit 587ff13

2 files changed

Lines changed: 4 additions & 4 deletions

File tree

BigQuery/tests/Unit/Connection/RestTest.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -214,9 +214,7 @@ private function getMetadata(Request $request)
214214
// does not; strip them so the metadata line offset matches on both.
215215
$lines = array_values(array_filter(
216216
explode(PHP_EOL, (string) $request->getBody()),
217-
function ($line) {
218-
return strpos($line, 'Content-Length:') !== 0;
219-
}
217+
fn ($line) => strpos($line, 'Content-Length:') !== 0
220218
));
221219
return json_decode($lines[4], true);
222220
}

Gax/src/ApiException.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -346,6 +346,8 @@ public static function createFromRpcStatus(Status $status)
346346

347347
/**
348348
* Creates an ApiException from a GuzzleHttp RequestException.
349+
* In Guzzle 7, this method expects a RequestException with a response.
350+
* In Guzzle 8, this method expects a ResponseException.
349351
*
350352
* @param RequestException $ex
351353
* @param boolean $isStream
@@ -357,7 +359,7 @@ public static function createFromRequestException(RequestException $ex, bool $is
357359
// Guzzle 7 carries the response on RequestException, Guzzle 8 only on
358360
// its ResponseException subclass, hence the method_exists() check.
359361
$res = method_exists($ex, 'getResponse') ? $ex->getResponse() : null;
360-
$body = (string) $res->getBody();
362+
$body = (string) $res?->getBody();
361363
$decoded = json_decode($body, true);
362364

363365
// A streaming response body will return one error in an array. Parse

0 commit comments

Comments
 (0)