Skip to content

Commit 8889fb0

Browse files
NyholmOskarStark
authored andcommitted
[Notifier] Make sure Http TransportException is not leaking
1 parent c425182 commit 8889fb0

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
@@ -19,6 +19,7 @@
1919
use Symfony\Component\Notifier\Message\SentMessage;
2020
use Symfony\Component\Notifier\Transport\AbstractTransport;
2121
use Symfony\Contracts\EventDispatcher\EventDispatcherInterface;
22+
use Symfony\Contracts\HttpClient\Exception\TransportExceptionInterface;
2223
use Symfony\Contracts\HttpClient\HttpClientInterface;
2324

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

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

0 commit comments

Comments
 (0)