From de2489c1e4c1e1ae5bb7c2dd4779af144e3eaa2b Mon Sep 17 00:00:00 2001 From: Maxime Pelletier Date: Mon, 23 Jan 2023 12:27:56 -0500 Subject: [PATCH] Attach errors to NotFound exception to be able to always have the full error response available --- src/Firebase/Messaging.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Firebase/Messaging.php b/src/Firebase/Messaging.php index d6f44350..9e90b851 100644 --- a/src/Firebase/Messaging.php +++ b/src/Firebase/Messaging.php @@ -58,7 +58,7 @@ public function send(Message|array $message, bool $validateOnly = false): array $token = Json::decode(Json::encode($message), true)['token'] ?? null; if ($token) { - throw NotFound::becauseTokenNotFound($token); + throw NotFound::becauseTokenNotFound($token, $e->errors()); } throw $e; @@ -189,8 +189,8 @@ public function getAppInstance(RegistrationToken|string $registrationToken): App try { return $this->appInstanceApi->getAppInstanceAsync($token)->wait(); - } catch (NotFound) { - throw NotFound::becauseTokenNotFound($token->value()); + } catch (NotFound $e) { + throw NotFound::becauseTokenNotFound($token->value(), $e->errors()); } catch (MessagingException $e) { // The token is invalid throw new InvalidArgument("The registration token '{$token}' is invalid or not available", $e->getCode(), $e);