From a5887c375b08969dcc92eeaae332171d2736ecf0 Mon Sep 17 00:00:00 2001 From: Marc Zampetti Date: Mon, 16 Mar 2015 16:17:57 -0400 Subject: [PATCH] Added logic to check to see if the $content->errors object exists, and only then us it to generate the exception. --- src/Github/Api.php | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src/Github/Api.php b/src/Github/Api.php index e5487fc..136bc97 100644 --- a/src/Github/Api.php +++ b/src/Github/Api.php @@ -279,9 +279,16 @@ public function decode(Http\Response $response, array $okCodes = NULL) throw new NotFoundException('Resource not found or not authorized to access.', $code, NULL, $response); case Http\Response::S422_UNPROCESSABLE_ENTITY: - $message = $content->message . implode(', ', array_map(function($error) { - return '[' . implode(':', (array) $error) . ']'; - }, $content->errors)); + if ( ! empty($content->errors) ) + { + $message = $content->message . implode(', ', array_map(function($error) { + return '[' . implode(':', (array) $error) . ']'; + }, $content->errors)); + } + else { + $message = $content->message; + } + throw new UnprocessableEntityException($message, $code, NULL, $response); }