Skip to content

Commit 0ce1f09

Browse files
authored
feature #880 Make invalid request error more clear (acrobat)
This PR was merged into the 2.15.x-dev branch. Discussion ---------- Closes #879 and closes #760 Commits ------- f84efb4 Make invalid request error more clear
2 parents d557dc4 + f84efb4 commit 0ce1f09

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

lib/Github/HttpClient/Plugin/GithubExceptionThrower.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ public function doHandleRequest(RequestInterface $request, callable $next, calla
4848
$content = ResponseMediator::getContent($response);
4949
if (is_array($content) && isset($content['message'])) {
5050
if (400 === $response->getStatusCode()) {
51-
throw new ErrorException($content['message'], 400);
51+
throw new ErrorException(sprintf('%s (%s)', $content['message'], $response->getReasonPhrase()), 400);
5252
}
5353

5454
if (422 === $response->getStatusCode() && isset($content['errors'])) {

test/Github/Tests/HttpClient/Plugin/GithubExceptionThrowerTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,11 +92,11 @@ public static function responseProvider()
9292
],
9393
json_encode(
9494
[
95-
'message' => 'Bad Request',
95+
'message' => 'Problems parsing JSON',
9696
]
9797
)
9898
),
99-
'exception' => new \Github\Exception\ErrorException('Bad Request', 400),
99+
'exception' => new \Github\Exception\ErrorException('Problems parsing JSON (Bad Request)', 400),
100100
],
101101
'422 Unprocessable Entity' => [
102102
'response' => new Response(

0 commit comments

Comments
 (0)