diff --git a/src/Http/GuzzleHttpClient.php b/src/Http/GuzzleHttpClient.php index 8bee107..0fe803b 100644 --- a/src/Http/GuzzleHttpClient.php +++ b/src/Http/GuzzleHttpClient.php @@ -467,7 +467,7 @@ private function buildApiException( if (!$parsedEnvelope) { // HTTP layer succeeded, body is unparseable as APIError. - $message = 'failed to parse error response'; + $message = sprintf('failed to parse error response: unexpected server response code %d', $statusCode); } if ($statusCode === 429) { diff --git a/tests/Exceptions/ErrorHandlingTest.php b/tests/Exceptions/ErrorHandlingTest.php index 2116157..3680122 100644 --- a/tests/Exceptions/ErrorHandlingTest.php +++ b/tests/Exceptions/ErrorHandlingTest.php @@ -106,7 +106,7 @@ public function unparseableErrorResponseFallsBackToSentinelMessage(): void self::assertSame(500, $e->getStatusCode()); self::assertSame(500, $e->getCode(), 'getCode() returns HTTP status (back-compat)'); self::assertSame(0, $e->getApiErrorCode(), 'APIError.code is 0 on unparseable body'); - self::assertSame('failed to parse error response', $e->getMessage()); + self::assertSame('failed to parse error response: unexpected server response code 500', $e->getMessage()); self::assertSame('<<>>', $e->getRawResponseBody()); self::assertNotNull($e->getPrevious(), 'cause chain must point to the JSON parse error'); self::assertInstanceOf(\JsonException::class, $e->getPrevious());