Skip to content

Commit 9503d37

Browse files
committed
Merge branch '5.2' into 5.3
* 5.2: [Notifier] Make sure Http TransportException is not leaking
2 parents eaf120f + 8889fb0 commit 9503d37

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

LinkedInTransport.php

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
use Symfony\Component\Notifier\Message\SentMessage;
2121
use Symfony\Component\Notifier\Transport\AbstractTransport;
2222
use Symfony\Contracts\EventDispatcher\EventDispatcherInterface;
23+
use Symfony\Contracts\HttpClient\Exception\TransportExceptionInterface;
2324
use Symfony\Contracts\HttpClient\HttpClientInterface;
2425

2526
/**
@@ -80,7 +81,13 @@ protected function doSend(MessageInterface $message): SentMessage
8081
'json' => array_filter($opts ? $opts->toArray() : $this->bodyFromMessageWithNoOption($message)),
8182
]);
8283

83-
if (201 !== $response->getStatusCode()) {
84+
try {
85+
$statusCode = $response->getStatusCode();
86+
} catch (TransportExceptionInterface $e) {
87+
throw new TransportException('Could not reach the remote LinkedIn server.', $response, 0, $e);
88+
}
89+
90+
if (201 !== $statusCode) {
8491
throw new TransportException(sprintf('Unable to post the Linkedin message: "%s".', $response->getContent(false)), $response);
8592
}
8693

0 commit comments

Comments
 (0)