From badae8f295ac953230551bd014a3981921df078e Mon Sep 17 00:00:00 2001 From: Matthew Grasmick Date: Tue, 17 Sep 2024 13:07:23 -0400 Subject: [PATCH] Add error_description to exception message (#57) * Include error_description in exception message --- src/Provider/Apple.php | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/Provider/Apple.php b/src/Provider/Apple.php index f8afdf4..6a2caa1 100644 --- a/src/Provider/Apple.php +++ b/src/Provider/Apple.php @@ -199,8 +199,15 @@ protected function getDefaultScopes() protected function checkResponse(ResponseInterface $response, $data) { if ($response->getStatusCode() >= 400) { + $message = $response->getReasonPhrase(); + if (array_key_exists('error', $data)) { + $message = $data['error']; + } + if (array_key_exists('error_description', $data)) { + $message .= ': ' . $data['error_description']; + } throw new AppleAccessDeniedException( - array_key_exists('error', $data) ? $data['error'] : $response->getReasonPhrase(), + $message, array_key_exists('code', $data) ? $data['code'] : $response->getStatusCode(), $response );