Skip to content

Commit 5e765f8

Browse files
author
Mohamed Khaled
committed
Remove special 400 handling from ResponseUtil
1 parent e16fba4 commit 5e765f8

File tree

2 files changed

+2
-9
lines changed

2 files changed

+2
-9
lines changed

src/Providers/Http/Util/ResponseUtil.php

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -50,13 +50,6 @@ public static function throwIfNotSuccessful(Response $response): void
5050

5151
// 4xx Client Errors
5252
if ($statusCode >= 400 && $statusCode < 500) {
53-
// Special handling for 400 Bad Request
54-
if ($statusCode === 400) {
55-
$body = (string) $response->getBody();
56-
$errorDetail = $body ? substr($body, 0, 200) : 'Invalid request parameters';
57-
throw ClientException::fromBadRequestResponse($errorDetail);
58-
}
59-
// General 4xx client errors
6053
throw ClientException::fromClientError($response);
6154
}
6255

tests/unit/Providers/Http/Util/ResponseUtilTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,11 +57,11 @@ public function testThrowIfNotSuccessfulThrowsClientExceptionFor400BadRequest():
5757
$response = $this->createMock(Response::class);
5858
$response->method('isSuccessful')->willReturn(false);
5959
$response->method('getStatusCode')->willReturn(400);
60-
$response->method('getBody')->willReturn('');
60+
$response->method('getData')->willReturn([]);
6161

6262
$this->expectException(ClientException::class);
6363
$this->expectExceptionCode(400);
64-
$this->expectExceptionMessage('Bad request (400): Invalid request parameters');
64+
$this->expectExceptionMessage('Client error (400): Request was rejected due to client-side issue');
6565

6666
ResponseUtil::throwIfNotSuccessful($response);
6767
}

0 commit comments

Comments
 (0)