Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 38157fc

Browse filesBrowse files
committed
[Notifier] UnsupportedMessageTypeException for notifier transports
1 parent 9d40bd8 commit 38157fc
Copy full SHA for 38157fc

19 files changed

+70
-28
lines changed

‎src/Symfony/Component/Notifier/Bridge/Discord/DiscordTransport.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Notifier/Bridge/Discord/DiscordTransport.php
+2-1Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313

1414
use Symfony\Component\Notifier\Exception\LogicException;
1515
use Symfony\Component\Notifier\Exception\TransportException;
16+
use Symfony\Component\Notifier\Exception\UnsupportedMessageTypeException;
1617
use Symfony\Component\Notifier\Message\ChatMessage;
1718
use Symfony\Component\Notifier\Message\MessageInterface;
1819
use Symfony\Component\Notifier\Message\SentMessage;
@@ -59,7 +60,7 @@ public function supports(MessageInterface $message): bool
5960
protected function doSend(MessageInterface $message): SentMessage
6061
{
6162
if (!$message instanceof ChatMessage) {
62-
throw new LogicException(sprintf('The "%s" transport only supports instances of "%s" (instance of "%s" given).', __CLASS__, ChatMessage::class, get_debug_type($message)));
63+
throw new UnsupportedMessageTypeException(__CLASS__, ChatMessage::class, $message);
6364
}
6465

6566
$messageOptions = $message->getOptions();

‎src/Symfony/Component/Notifier/Bridge/Esendex/EsendexTransport.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Notifier/Bridge/Esendex/EsendexTransport.php
+2-2Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@
1313

1414
use Symfony\Component\HttpClient\Exception\JsonException;
1515
use Symfony\Component\HttpClient\Exception\TransportException as HttpClientTransportException;
16-
use Symfony\Component\Notifier\Exception\LogicException;
1716
use Symfony\Component\Notifier\Exception\TransportException;
17+
use Symfony\Component\Notifier\Exception\UnsupportedMessageTypeException;
1818
use Symfony\Component\Notifier\Message\MessageInterface;
1919
use Symfony\Component\Notifier\Message\SentMessage;
2020
use Symfony\Component\Notifier\Message\SmsMessage;
@@ -55,7 +55,7 @@ public function supports(MessageInterface $message): bool
5555
protected function doSend(MessageInterface $message): SentMessage
5656
{
5757
if (!$message instanceof SmsMessage) {
58-
throw new LogicException(sprintf('The "%s" transport only supports instances of "%s" (instance of "%s" given).', __CLASS__, SmsMessage::class, get_debug_type($message)));
58+
throw new UnsupportedMessageTypeException(__CLASS__, SmsMessage::class, $message);
5959
}
6060

6161
$messageData = [

‎src/Symfony/Component/Notifier/Bridge/Firebase/FirebaseTransport.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Notifier/Bridge/Firebase/FirebaseTransport.php
+2-2Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@
1212
namespace Symfony\Component\Notifier\Bridge\Firebase;
1313

1414
use Symfony\Component\Notifier\Exception\InvalidArgumentException;
15-
use Symfony\Component\Notifier\Exception\LogicException;
1615
use Symfony\Component\Notifier\Exception\TransportException;
16+
use Symfony\Component\Notifier\Exception\UnsupportedMessageTypeException;
1717
use Symfony\Component\Notifier\Message\ChatMessage;
1818
use Symfony\Component\Notifier\Message\MessageInterface;
1919
use Symfony\Component\Notifier\Message\SentMessage;
@@ -54,7 +54,7 @@ public function supports(MessageInterface $message): bool
5454
protected function doSend(MessageInterface $message): SentMessage
5555
{
5656
if (!$message instanceof ChatMessage) {
57-
throw new LogicException(sprintf('The "%s" transport only supports instances of "%s" (instance of "%s" given).', __CLASS__, ChatMessage::class, get_debug_type($message)));
57+
throw new UnsupportedMessageTypeException(__CLASS__, ChatMessage::class, $message);
5858
}
5959

6060
$endpoint = sprintf('https://%s', $this->getEndpoint());

‎src/Symfony/Component/Notifier/Bridge/GoogleChat/GoogleChatTransport.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Notifier/Bridge/GoogleChat/GoogleChatTransport.php
+2-1Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
use Symfony\Component\HttpClient\Exception\JsonException;
1515
use Symfony\Component\Notifier\Exception\LogicException;
1616
use Symfony\Component\Notifier\Exception\TransportException;
17+
use Symfony\Component\Notifier\Exception\UnsupportedMessageTypeException;
1718
use Symfony\Component\Notifier\Message\ChatMessage;
1819
use Symfony\Component\Notifier\Message\MessageInterface;
1920
use Symfony\Component\Notifier\Message\SentMessage;
@@ -89,7 +90,7 @@ public function supports(MessageInterface $message): bool
8990
protected function doSend(MessageInterface $message): SentMessage
9091
{
9192
if (!$message instanceof ChatMessage) {
92-
throw new LogicException(sprintf('The "%s" transport only supports instances of "%s" (instance of "%s" given).', __CLASS__, ChatMessage::class, \get_class($message)));
93+
throw new UnsupportedMessageTypeException(__CLASS__, ChatMessage::class, $message);
9394
}
9495
if ($message->getOptions() && !$message->getOptions() instanceof GoogleChatOptions) {
9596
throw new LogicException(sprintf('The "%s" transport only supports instances of "%s" for options.', __CLASS__, GoogleChatOptions::class));

‎src/Symfony/Component/Notifier/Bridge/Infobip/InfobipTransport.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Notifier/Bridge/Infobip/InfobipTransport.php
+2-2Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@
1111

1212
namespace Symfony\Component\Notifier\Bridge\Infobip;
1313

14-
use Symfony\Component\Notifier\Exception\LogicException;
1514
use Symfony\Component\Notifier\Exception\TransportException;
15+
use Symfony\Component\Notifier\Exception\UnsupportedMessageTypeException;
1616
use Symfony\Component\Notifier\Message\MessageInterface;
1717
use Symfony\Component\Notifier\Message\SentMessage;
1818
use Symfony\Component\Notifier\Message\SmsMessage;
@@ -52,7 +52,7 @@ public function supports(MessageInterface $message): bool
5252
protected function doSend(MessageInterface $message): SentMessage
5353
{
5454
if (!$message instanceof SmsMessage) {
55-
throw new LogicException(sprintf('The "%s" transport only supports instances of "%s" (instance of "%s" given).', __CLASS__, SmsMessage::class, get_debug_type($message)));
55+
throw new UnsupportedMessageTypeException(__CLASS__, SmsMessage::class, $message);
5656
}
5757

5858
$endpoint = sprintf('https://%s/sms/2/text/advanced', $this->getEndpoint());

‎src/Symfony/Component/Notifier/Bridge/LinkedIn/LinkedInTransport.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Notifier/Bridge/LinkedIn/LinkedInTransport.php
+2-1Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
use Symfony\Component\Notifier\Bridge\LinkedIn\Share\AuthorShare;
1515
use Symfony\Component\Notifier\Exception\LogicException;
1616
use Symfony\Component\Notifier\Exception\TransportException;
17+
use Symfony\Component\Notifier\Exception\UnsupportedMessageTypeException;
1718
use Symfony\Component\Notifier\Message\ChatMessage;
1819
use Symfony\Component\Notifier\Message\MessageInterface;
1920
use Symfony\Component\Notifier\Message\SentMessage;
@@ -61,7 +62,7 @@ public function supports(MessageInterface $message): bool
6162
protected function doSend(MessageInterface $message): SentMessage
6263
{
6364
if (!$message instanceof ChatMessage) {
64-
throw new LogicException(sprintf('The "%s" transport only supports instances of "%s" (instance of "%s" given).', __CLASS__, ChatMessage::class, \get_class($message)));
65+
throw new UnsupportedMessageTypeException(__CLASS__, ChatMessage::class, $message);
6566
}
6667
if ($message->getOptions() && !$message->getOptions() instanceof LinkedInOptions) {
6768
throw new LogicException(sprintf('The "%s" transport only supports instances of "%s" for options.', __CLASS__, LinkedInOptions::class));

‎src/Symfony/Component/Notifier/Bridge/Mattermost/MattermostTransport.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Notifier/Bridge/Mattermost/MattermostTransport.php
+2-2Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@
1111

1212
namespace Symfony\Component\Notifier\Bridge\Mattermost;
1313

14-
use Symfony\Component\Notifier\Exception\LogicException;
1514
use Symfony\Component\Notifier\Exception\TransportException;
15+
use Symfony\Component\Notifier\Exception\UnsupportedMessageTypeException;
1616
use Symfony\Component\Notifier\Message\ChatMessage;
1717
use Symfony\Component\Notifier\Message\MessageInterface;
1818
use Symfony\Component\Notifier\Message\SentMessage;
@@ -54,7 +54,7 @@ public function supports(MessageInterface $message): bool
5454
protected function doSend(MessageInterface $message): SentMessage
5555
{
5656
if (!$message instanceof ChatMessage) {
57-
throw new LogicException(sprintf('The "%s" transport only supports instances of "%s" (instance of "%s" given).', __CLASS__, ChatMessage::class, get_debug_type($message)));
57+
throw new UnsupportedMessageTypeException(__CLASS__, ChatMessage::class, $message);
5858
}
5959

6060
$endpoint = sprintf('https://%s/api/v4/posts', $this->getEndpoint());

‎src/Symfony/Component/Notifier/Bridge/Mobyt/MobytTransport.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Notifier/Bridge/Mobyt/MobytTransport.php
+2-1Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313

1414
use Symfony\Component\Notifier\Exception\LogicException;
1515
use Symfony\Component\Notifier\Exception\TransportException;
16+
use Symfony\Component\Notifier\Exception\UnsupportedMessageTypeException;
1617
use Symfony\Component\Notifier\Message\MessageInterface;
1718
use Symfony\Component\Notifier\Message\SentMessage;
1819
use Symfony\Component\Notifier\Message\SmsMessage;
@@ -57,7 +58,7 @@ public function supports(MessageInterface $message): bool
5758
protected function doSend(MessageInterface $message): SentMessage
5859
{
5960
if (!$message instanceof SmsMessage) {
60-
throw new LogicException(sprintf('The "%s" transport only supports instances of "%s" (instance of "%s" given).', __CLASS__, SmsMessage::class, \get_class($message)));
61+
throw new UnsupportedMessageTypeException(__CLASS__, SmsMessage::class, $message);
6162
}
6263

6364
if ($message->getOptions() && !$message->getOptions() instanceof MobytOptions) {

‎src/Symfony/Component/Notifier/Bridge/Nexmo/NexmoTransport.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Notifier/Bridge/Nexmo/NexmoTransport.php
+2-2Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@
1111

1212
namespace Symfony\Component\Notifier\Bridge\Nexmo;
1313

14-
use Symfony\Component\Notifier\Exception\LogicException;
1514
use Symfony\Component\Notifier\Exception\TransportException;
15+
use Symfony\Component\Notifier\Exception\UnsupportedMessageTypeException;
1616
use Symfony\Component\Notifier\Message\MessageInterface;
1717
use Symfony\Component\Notifier\Message\SentMessage;
1818
use Symfony\Component\Notifier\Message\SmsMessage;
@@ -55,7 +55,7 @@ public function supports(MessageInterface $message): bool
5555
protected function doSend(MessageInterface $message): SentMessage
5656
{
5757
if (!$message instanceof SmsMessage) {
58-
throw new LogicException(sprintf('The "%s" transport only supports instances of "%s" (instance of "%s" given).', __CLASS__, SmsMessage::class, get_debug_type($message)));
58+
throw new UnsupportedMessageTypeException(__CLASS__, SmsMessage::class, $message);
5959
}
6060

6161
$response = $this->client->request('POST', 'https://'.$this->getEndpoint().'/sms/json', [

‎src/Symfony/Component/Notifier/Bridge/OvhCloud/OvhCloudTransport.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Notifier/Bridge/OvhCloud/OvhCloudTransport.php
+2-2Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@
1111

1212
namespace Symfony\Component\Notifier\Bridge\OvhCloud;
1313

14-
use Symfony\Component\Notifier\Exception\LogicException;
1514
use Symfony\Component\Notifier\Exception\TransportException;
15+
use Symfony\Component\Notifier\Exception\UnsupportedMessageTypeException;
1616
use Symfony\Component\Notifier\Message\MessageInterface;
1717
use Symfony\Component\Notifier\Message\SentMessage;
1818
use Symfony\Component\Notifier\Message\SmsMessage;
@@ -57,7 +57,7 @@ public function supports(MessageInterface $message): bool
5757
protected function doSend(MessageInterface $message): SentMessage
5858
{
5959
if (!$message instanceof SmsMessage) {
60-
throw new LogicException(sprintf('The "%s" transport only supports instances of "%s" (instance of "%s" given).', __CLASS__, SmsMessage::class, get_debug_type($message)));
60+
throw new UnsupportedMessageTypeException(__CLASS__, SmsMessage::class, $message);
6161
}
6262

6363
$endpoint = sprintf('https://%s/1.0/sms/%s/jobs', $this->getEndpoint(), $this->serviceName);

‎src/Symfony/Component/Notifier/Bridge/RocketChat/RocketChatTransport.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Notifier/Bridge/RocketChat/RocketChatTransport.php
+2-1Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313

1414
use Symfony\Component\Notifier\Exception\LogicException;
1515
use Symfony\Component\Notifier\Exception\TransportException;
16+
use Symfony\Component\Notifier\Exception\UnsupportedMessageTypeException;
1617
use Symfony\Component\Notifier\Message\ChatMessage;
1718
use Symfony\Component\Notifier\Message\MessageInterface;
1819
use Symfony\Component\Notifier\Message\SentMessage;
@@ -59,7 +60,7 @@ public function supports(MessageInterface $message): bool
5960
protected function doSend(MessageInterface $message): SentMessage
6061
{
6162
if (!$message instanceof ChatMessage) {
62-
throw new LogicException(sprintf('The "%s" transport only supports instances of "%s" (instance of "%s" given).', __CLASS__, ChatMessage::class, get_debug_type($message)));
63+
throw new UnsupportedMessageTypeException(__CLASS__, ChatMessage::class, $message);
6364
}
6465
if ($message->getOptions() && !$message->getOptions() instanceof RocketChatOptions) {
6566
throw new LogicException(sprintf('The "%s" transport only supports instances of "%s" for options.', __CLASS__, RocketChatOptions::class));

‎src/Symfony/Component/Notifier/Bridge/Sendinblue/SendinblueTransport.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Notifier/Bridge/Sendinblue/SendinblueTransport.php
+2-2Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@
1111

1212
namespace Symfony\Component\Notifier\Bridge\Sendinblue;
1313

14-
use Symfony\Component\Notifier\Exception\LogicException;
1514
use Symfony\Component\Notifier\Exception\TransportException;
15+
use Symfony\Component\Notifier\Exception\UnsupportedMessageTypeException;
1616
use Symfony\Component\Notifier\Message\MessageInterface;
1717
use Symfony\Component\Notifier\Message\SentMessage;
1818
use Symfony\Component\Notifier\Message\SmsMessage;
@@ -53,7 +53,7 @@ public function supports(MessageInterface $message): bool
5353
protected function doSend(MessageInterface $message): SentMessage
5454
{
5555
if (!$message instanceof SmsMessage) {
56-
throw new LogicException(sprintf('The "%s" transport only supports instances of "%s" (instance of "%s" given).', __CLASS__, SmsMessage::class, get_debug_type($message)));
56+
throw new UnsupportedMessageTypeException(__CLASS__, SmsMessage::class, $message);
5757
}
5858

5959
$response = $this->client->request('POST', 'https://'.$this->getEndpoint().'/v3/transactionalSMS/sms', [

‎src/Symfony/Component/Notifier/Bridge/Sinch/SinchTransport.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Notifier/Bridge/Sinch/SinchTransport.php
+2-2Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@
1111

1212
namespace Symfony\Component\Notifier\Bridge\Sinch;
1313

14-
use Symfony\Component\Notifier\Exception\LogicException;
1514
use Symfony\Component\Notifier\Exception\TransportException;
15+
use Symfony\Component\Notifier\Exception\UnsupportedMessageTypeException;
1616
use Symfony\Component\Notifier\Message\MessageInterface;
1717
use Symfony\Component\Notifier\Message\SentMessage;
1818
use Symfony\Component\Notifier\Message\SmsMessage;
@@ -55,7 +55,7 @@ public function supports(MessageInterface $message): bool
5555
protected function doSend(MessageInterface $message): SentMessage
5656
{
5757
if (!$message instanceof SmsMessage) {
58-
throw new LogicException(sprintf('The "%s" transport only supports instances of "%s" (instance of "%s" given).', __CLASS__, SmsMessage::class, get_debug_type($message)));
58+
throw new UnsupportedMessageTypeException(__CLASS__, SmsMessage::class, $message);
5959
}
6060

6161
$endpoint = sprintf('https://%s/xms/v1/%s/batches', $this->getEndpoint(), $this->accountSid);

‎src/Symfony/Component/Notifier/Bridge/Slack/SlackTransport.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Notifier/Bridge/Slack/SlackTransport.php
+2-1Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313

1414
use Symfony\Component\Notifier\Exception\LogicException;
1515
use Symfony\Component\Notifier\Exception\TransportException;
16+
use Symfony\Component\Notifier\Exception\UnsupportedMessageTypeException;
1617
use Symfony\Component\Notifier\Message\ChatMessage;
1718
use Symfony\Component\Notifier\Message\MessageInterface;
1819
use Symfony\Component\Notifier\Message\SentMessage;
@@ -59,7 +60,7 @@ public function supports(MessageInterface $message): bool
5960
protected function doSend(MessageInterface $message): SentMessage
6061
{
6162
if (!$message instanceof ChatMessage) {
62-
throw new LogicException(sprintf('The "%s" transport only supports instances of "%s" (instance of "%s" given).', __CLASS__, ChatMessage::class, get_debug_type($message)));
63+
throw new UnsupportedMessageTypeException(__CLASS__, ChatMessage::class, $message);
6364
}
6465
if ($message->getOptions() && !$message->getOptions() instanceof SlackOptions) {
6566
throw new LogicException(sprintf('The "%s" transport only supports instances of "%s" for options.', __CLASS__, SlackOptions::class));

‎src/Symfony/Component/Notifier/Bridge/Smsapi/SmsapiTransport.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Notifier/Bridge/Smsapi/SmsapiTransport.php
+2-2Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@
1111

1212
namespace Symfony\Component\Notifier\Bridge\Smsapi;
1313

14-
use Symfony\Component\Notifier\Exception\LogicException;
1514
use Symfony\Component\Notifier\Exception\TransportException;
15+
use Symfony\Component\Notifier\Exception\UnsupportedMessageTypeException;
1616
use Symfony\Component\Notifier\Message\MessageInterface;
1717
use Symfony\Component\Notifier\Message\SentMessage;
1818
use Symfony\Component\Notifier\Message\SmsMessage;
@@ -52,7 +52,7 @@ public function supports(MessageInterface $message): bool
5252
protected function doSend(MessageInterface $message): SentMessage
5353
{
5454
if (!$message instanceof SmsMessage) {
55-
throw new LogicException(sprintf('The "%s" transport only supports instances of "%s" (instance of "%s" given).', __CLASS__, SmsMessage::class, get_debug_type($message)));
55+
throw new UnsupportedMessageTypeException(__CLASS__, SmsMessage::class, $message);
5656
}
5757

5858
$endpoint = sprintf('https://%s/sms.do', $this->getEndpoint());

‎src/Symfony/Component/Notifier/Bridge/Telegram/TelegramTransport.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Notifier/Bridge/Telegram/TelegramTransport.php
+2-1Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313

1414
use Symfony\Component\Notifier\Exception\LogicException;
1515
use Symfony\Component\Notifier\Exception\TransportException;
16+
use Symfony\Component\Notifier\Exception\UnsupportedMessageTypeException;
1617
use Symfony\Component\Notifier\Message\ChatMessage;
1718
use Symfony\Component\Notifier\Message\MessageInterface;
1819
use Symfony\Component\Notifier\Message\SentMessage;
@@ -64,7 +65,7 @@ public function supports(MessageInterface $message): bool
6465
protected function doSend(MessageInterface $message): SentMessage
6566
{
6667
if (!$message instanceof ChatMessage) {
67-
throw new LogicException(sprintf('The "%s" transport only supports instances of "%s" (instance of "%s" given).', __CLASS__, ChatMessage::class, get_debug_type($message)));
68+
throw new UnsupportedMessageTypeException(__CLASS__, ChatMessage::class, $message);
6869
}
6970

7071
if ($message->getOptions() && !$message->getOptions() instanceof TelegramOptions) {

‎src/Symfony/Component/Notifier/Bridge/Twilio/TwilioTransport.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Notifier/Bridge/Twilio/TwilioTransport.php
+2-2Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@
1111

1212
namespace Symfony\Component\Notifier\Bridge\Twilio;
1313

14-
use Symfony\Component\Notifier\Exception\LogicException;
1514
use Symfony\Component\Notifier\Exception\TransportException;
15+
use Symfony\Component\Notifier\Exception\UnsupportedMessageTypeException;
1616
use Symfony\Component\Notifier\Message\MessageInterface;
1717
use Symfony\Component\Notifier\Message\SentMessage;
1818
use Symfony\Component\Notifier\Message\SmsMessage;
@@ -55,7 +55,7 @@ public function supports(MessageInterface $message): bool
5555
protected function doSend(MessageInterface $message): SentMessage
5656
{
5757
if (!$message instanceof SmsMessage) {
58-
throw new LogicException(sprintf('The "%s" transport only supports instances of "%s" (instance of "%s" given).', __CLASS__, SmsMessage::class, get_debug_type($message)));
58+
throw new UnsupportedMessageTypeException(__CLASS__, SmsMessage::class, $message);
5959
}
6060

6161
$endpoint = sprintf('https://%s/2010-04-01/Accounts/%s/Messages.json', $this->getEndpoint(), $this->accountSid);

‎src/Symfony/Component/Notifier/Bridge/Zulip/ZulipTransport.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Notifier/Bridge/Zulip/ZulipTransport.php
+2-1Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313

1414
use Symfony\Component\Notifier\Exception\LogicException;
1515
use Symfony\Component\Notifier\Exception\TransportException;
16+
use Symfony\Component\Notifier\Exception\UnsupportedMessageTypeException;
1617
use Symfony\Component\Notifier\Message\ChatMessage;
1718
use Symfony\Component\Notifier\Message\MessageInterface;
1819
use Symfony\Component\Notifier\Message\SentMessage;
@@ -56,7 +57,7 @@ public function supports(MessageInterface $message): bool
5657
protected function doSend(MessageInterface $message): SentMessage
5758
{
5859
if (!$message instanceof ChatMessage) {
59-
throw new LogicException(sprintf('The "%s" transport only supports instances of "%s" (instance of "%s" given).', __CLASS__, ChatMessage::class, get_debug_type($message)));
60+
throw new UnsupportedMessageTypeException(__CLASS__, ChatMessage::class, $message);
6061
}
6162

6263
if (null !== $message->getOptions() && !($message->getOptions() instanceof ZulipOptions)) {
+34Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
<?php
2+
3+
/*
4+
* This file is part of the Symfony package.
5+
*
6+
* (c) Fabien Potencier <fabien@symfony.com>
7+
*
8+
* For the full copyright and license information, please view the LICENSE
9+
* file that was distributed with this source code.
10+
*/
11+
12+
namespace Symfony\Component\Notifier\Exception;
13+
14+
use Symfony\Component\Notifier\Message\MessageInterface;
15+
16+
/**
17+
* @author Oskar Stark <oskarstark@googlemail.com>
18+
*
19+
* @experimental in 5.3
20+
*/
21+
class UnsupportedMessageTypeException extends LogicException
22+
{
23+
public function __construct(string $transport, string $supported, MessageInterface $given)
24+
{
25+
$message = sprintf(
26+
'The "%s" transport only supports instances of "%s" (instance of "%s" given).',
27+
\get_class($transport),
28+
$supported,
29+
get_debug_type($given)
30+
);
31+
32+
parent::__construct($message);
33+
}
34+
}

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.