Skip to content

Commit e5ca1d2

Browse files
committed
Merge branch '5.3' into 5.4
* 5.3: [Notifier] [5.3] Make sure Http TransportException is not leaking
2 parents 0b38275 + fafed15 commit e5ca1d2

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

MessageBirdTransport.php

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
use Symfony\Component\Notifier\Message\SmsMessage;
1919
use Symfony\Component\Notifier\Transport\AbstractTransport;
2020
use Symfony\Contracts\EventDispatcher\EventDispatcherInterface;
21+
use Symfony\Contracts\HttpClient\Exception\TransportExceptionInterface;
2122
use Symfony\Contracts\HttpClient\HttpClientInterface;
2223

2324
/**
@@ -64,7 +65,13 @@ protected function doSend(MessageInterface $message): SentMessage
6465
],
6566
]);
6667

67-
if (201 !== $response->getStatusCode()) {
68+
try {
69+
$statusCode = $response->getStatusCode();
70+
} catch (TransportExceptionInterface $e) {
71+
throw new TransportException('Could not reach the remote MessageBird server.', $response, 0, $e);
72+
}
73+
74+
if (201 !== $statusCode) {
6875
if (!isset($response->toArray(false)['errors'])) {
6976
throw new TransportException('Unable to send the SMS.', $response);
7077
}

0 commit comments

Comments
 (0)