Skip to content

Commit 6c28aaa

Browse files
committed
Merge branch '5.2' into 5.3
* 5.2: [Notifier] Make sure Http TransportException is not leaking
2 parents 298e4b9 + c154d2a commit 6c28aaa

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

SmsapiTransport.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
/**
@@ -65,7 +66,13 @@ protected function doSend(MessageInterface $message): SentMessage
6566
],
6667
]);
6768

68-
if (200 !== $response->getStatusCode()) {
69+
try {
70+
$statusCode = $response->getStatusCode();
71+
} catch (TransportExceptionInterface $e) {
72+
throw new TransportException('Could not reach the remote Smsapi server.', $response, 0, $e);
73+
}
74+
75+
if (200 !== $statusCode) {
6976
$error = $response->toArray(false);
7077

7178
throw new TransportException(sprintf('Unable to send the SMS: "%s".', $error['message']), $response);

0 commit comments

Comments
 (0)