Skip to content

Commit da77143

Browse files
committed
Add default error message
Github also throws `custom` error messages and the switch doesn't catch it. ```[errors] => Array         (             [0] => Array                 (                     [code] => custom                     [resource] => Repository                     [field] => name                     [message] => name can't be private. You are over your quota.                 )         )``` Adding a `default` fixes this.
1 parent 3242cf5 commit da77143

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

lib/Github/HttpClient/Listener/ErrorListener.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,10 +71,14 @@ public function postSend(RequestInterface $request, MessageInterface $response)
7171
$errors[] = sprintf('Field "%s" already exists, for resource "%s"', $error['field'], $error['resource']);
7272
break;
7373

74+
default:
75+
$errors[] = $error['message'];
76+
break;
77+
7478
}
7579
}
7680

77-
throw new ValidationFailedException('Validation Failed:' . implode(', ', $errors), 422);
81+
throw new ValidationFailedException('Validation Failed: ' . implode(', ', $errors), 422);
7882
}
7983
}
8084

0 commit comments

Comments
 (0)