From 1a4225096a9209099cc70735e89f73ed347de6b6 Mon Sep 17 00:00:00 2001 From: Graham Campbell Date: Tue, 5 Nov 2019 18:21:52 +0000 Subject: [PATCH] Fixed handling of validation errors --- lib/Github/HttpClient/Plugin/GithubExceptionThrower.php | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/lib/Github/HttpClient/Plugin/GithubExceptionThrower.php b/lib/Github/HttpClient/Plugin/GithubExceptionThrower.php index 933c06a5817..04f137f06cf 100644 --- a/lib/Github/HttpClient/Plugin/GithubExceptionThrower.php +++ b/lib/Github/HttpClient/Plugin/GithubExceptionThrower.php @@ -76,13 +76,18 @@ public function doHandleRequest(RequestInterface $request, callable $next, calla break; default: - $errors[] = $error['message']; + if (isset($error['message'])) { + $errors[] = $error['message']; + } break; } } - throw new ValidationFailedException('Validation Failed: '.implode(', ', $errors), 422); + throw new ValidationFailedException( + $errors ? 'Validation Failed: '.implode(', ', $errors) : 'Validation Failed', + 422 + ); } }