Skip to content

Commit 05a3319

Browse files
committed
provide a better missing error message
When github say's missing, it's not talking about the resource - it means something referenced in the data. For example, specifying a milestone that doesn't exist will return: ``` { "message": "Validation Failed" "documentation_url": "http"://developer.github.com/v3" "errors": [ { "value": 42, "resource": "Issue", "field": "milestone", "code": "missing" } ] } ``` Previously this would be reported as: > Validation Failed: Resource "Issue" not exists anymore Now it's reported as > The milestone 42 doesa not exist, for resource "Issue"
1 parent 3787a1b commit 05a3319

File tree

2 files changed

+2
-1
lines changed

2 files changed

+2
-1
lines changed

lib/Github/HttpClient/Listener/ErrorListener.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ public function postSend(RequestInterface $request, MessageInterface $response)
5757
foreach ($content['errors'] as $error) {
5858
switch ($error['code']) {
5959
case 'missing':
60-
$errors[] = sprintf('Resource "%s" not exists anymore', $error['resource']);
60+
$errors[] = sprintf('The %s %s does not exist, for resource "%s"', $error['field'], $error['value'], $error['resource']);
6161
break;
6262

6363
case 'missing_field':

test/Github/Tests/HttpClient/Listener/ErrorListenerTest.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,7 @@ public function shouldNotPassWhen422IsSentWithErrorCode($errorCode)
124124
array(
125125
'code' => $errorCode,
126126
'field' => 'test',
127+
'value' => 'wrong',
127128
'resource' => 'fake'
128129
)
129130
)

0 commit comments

Comments
 (0)