Skip to content

Commit

Permalink
improve handling of HTTP 410 'Gone' exception
Browse files Browse the repository at this point in the history
  • Loading branch information
leob committed Dec 7, 2024
1 parent eb731d4 commit 2b3eca8
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/ConnectionRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

use Aws\ApiGatewayManagementApi\ApiGatewayManagementApiClient;
use Aws\ApiGatewayManagementApi\Exception\ApiGatewayManagementApiException;
use Symfony\Component\HttpFoundation\Response;

class ConnectionRepository
{
Expand All @@ -30,8 +31,11 @@ public function sendMessage(string $connectionId, string $data): void
'Data' => $data,
]);
} catch (ApiGatewayManagementApiException $e) {
// GoneException: The connection with the provided id no longer exists.
if ($e->getAwsErrorCode() === 'GoneException') {
// GoneException: The connection with the provided id no longer exists
if (
$e->getStatusCode() === Response::HTTP_GONE ||
$e->getAwsErrorCode() === 'GoneException'
) {
$this->subscriptionRepository->clearConnection($connectionId);

return;
Expand Down

0 comments on commit 2b3eca8

Please sign in to comment.