Skip to content

Commit

Permalink
Merge pull request #47 from mehrshaddarzi/patch-1
Browse files Browse the repository at this point in the history
Add Connect Error PHP Curl
  • Loading branch information
AndyGaskell authored Nov 3, 2022
2 parents 64fb221 + 1bc0a3a commit 1971b3d
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions src/FcmClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -81,9 +81,13 @@ public function send(Request $request): array
$url = $request->getUrl();

// Create and send the request.
$response = $client->post($url, [
'json' => $request->getBody()
]);
try {
$response = $client->post($url, [
'json' => $request->getBody()
]);
} catch (GuzzleException $e) {
throw new FcmClientException('Failed to Connect: '.$e->getMessage());
}

// Decode the response body from json to a plain php array.
$body = json_decode($response->getBody()->getContents(), true);
Expand Down

0 comments on commit 1971b3d

Please sign in to comment.