diff --git a/src/Symfony/Component/Notifier/Bridge/Discord/DiscordTransport.php b/src/Symfony/Component/Notifier/Bridge/Discord/DiscordTransport.php index 70b638db19c4a..b8b865b81208e 100644 --- a/src/Symfony/Component/Notifier/Bridge/Discord/DiscordTransport.php +++ b/src/Symfony/Component/Notifier/Bridge/Discord/DiscordTransport.php @@ -11,7 +11,7 @@ namespace Symfony\Component\Notifier\Bridge\Discord; -use Symfony\Component\Notifier\Exception\LogicException; +use Symfony\Component\Notifier\Exception\LengthException; use Symfony\Component\Notifier\Exception\TransportException; use Symfony\Component\Notifier\Exception\UnsupportedMessageTypeException; use Symfony\Component\Notifier\Message\ChatMessage; @@ -67,7 +67,7 @@ protected function doSend(MessageInterface $message): SentMessage $content = $message->getSubject(); if (\strlen($content) > 2000) { - throw new LogicException('The subject length of a Discord message must not exceed 2000 characters.'); + throw new LengthException('The subject length of a Discord message must not exceed 2000 characters.'); } $endpoint = sprintf('https://%s/api/webhooks/%s/%s', $this->getEndpoint(), $this->webhookId, $this->token); diff --git a/src/Symfony/Component/Notifier/Bridge/Discord/Tests/DiscordTransportTest.php b/src/Symfony/Component/Notifier/Bridge/Discord/Tests/DiscordTransportTest.php index 5f034db10bd85..3a64c1bd76879 100644 --- a/src/Symfony/Component/Notifier/Bridge/Discord/Tests/DiscordTransportTest.php +++ b/src/Symfony/Component/Notifier/Bridge/Discord/Tests/DiscordTransportTest.php @@ -14,7 +14,7 @@ use PHPUnit\Framework\TestCase; use Symfony\Component\HttpClient\MockHttpClient; use Symfony\Component\Notifier\Bridge\Discord\DiscordTransport; -use Symfony\Component\Notifier\Exception\LogicException; +use Symfony\Component\Notifier\Exception\LengthException; use Symfony\Component\Notifier\Exception\TransportException; use Symfony\Component\Notifier\Exception\UnsupportedMessageTypeException; use Symfony\Component\Notifier\Message\ChatMessage; @@ -55,7 +55,7 @@ public function testSendChatMessageWithMoreThan2000CharsThrowsLogicException() { $transport = new DiscordTransport('testToken', 'testChannel', $this->createMock(HttpClientInterface::class)); - $this->expectException(LogicException::class); + $this->expectException(LengthException::class); $this->expectExceptionMessage('The subject length of a Discord message must not exceed 2000 characters.'); $transport->send(new ChatMessage(str_repeat('d', 2001))); diff --git a/src/Symfony/Component/Notifier/Bridge/Slack/Block/SlackHeaderBlock.php b/src/Symfony/Component/Notifier/Bridge/Slack/Block/SlackHeaderBlock.php index c958962f1b6a4..5a4d4189ca5b1 100644 --- a/src/Symfony/Component/Notifier/Bridge/Slack/Block/SlackHeaderBlock.php +++ b/src/Symfony/Component/Notifier/Bridge/Slack/Block/SlackHeaderBlock.php @@ -11,7 +11,7 @@ namespace Symfony\Component\Notifier\Bridge\Slack\Block; -use Symfony\Component\Notifier\Exception\LogicException; +use Symfony\Component\Notifier\Exception\LengthException; /** * @author Tomas Norkūnas @@ -26,7 +26,7 @@ final class SlackHeaderBlock extends AbstractSlackBlock public function __construct(string $text) { if (\strlen($text) > self::TEXT_LIMIT) { - throw new LogicException(sprintf('Maximum length for the text is %d characters.', self::TEXT_LIMIT)); + throw new LengthException(sprintf('Maximum length for the text is %d characters.', self::TEXT_LIMIT)); } $this->options = [ @@ -41,7 +41,7 @@ public function __construct(string $text) public function id(string $id): self { if (\strlen($id) > self::ID_LIMIT) { - throw new LogicException(sprintf('Maximum length for the block id is %d characters.', self::ID_LIMIT)); + throw new LengthException(sprintf('Maximum length for the block id is %d characters.', self::ID_LIMIT)); } $this->options['block_id'] = $id; diff --git a/src/Symfony/Component/Notifier/Bridge/Slack/Tests/Block/SlackHeaderBlockTest.php b/src/Symfony/Component/Notifier/Bridge/Slack/Tests/Block/SlackHeaderBlockTest.php index c899b1822c091..1174fe9712496 100644 --- a/src/Symfony/Component/Notifier/Bridge/Slack/Tests/Block/SlackHeaderBlockTest.php +++ b/src/Symfony/Component/Notifier/Bridge/Slack/Tests/Block/SlackHeaderBlockTest.php @@ -13,7 +13,7 @@ use PHPUnit\Framework\TestCase; use Symfony\Component\Notifier\Bridge\Slack\Block\SlackHeaderBlock; -use Symfony\Component\Notifier\Exception\LogicException; +use Symfony\Component\Notifier\Exception\LengthException; final class SlackHeaderBlockTest extends TestCase { @@ -34,7 +34,7 @@ public function testCanBeInstantiated(): void public function testThrowsWhenTextExceedsCharacterLimit(): void { - $this->expectException(LogicException::class); + $this->expectException(LengthException::class); $this->expectExceptionMessage('Maximum length for the text is 150 characters.'); new SlackHeaderBlock(str_repeat('h', 151)); @@ -42,7 +42,7 @@ public function testThrowsWhenTextExceedsCharacterLimit(): void public function testThrowsWhenBlockIdExceedsCharacterLimit(): void { - $this->expectException(LogicException::class); + $this->expectException(LengthException::class); $this->expectExceptionMessage('Maximum length for the block id is 255 characters.'); $header = new SlackHeaderBlock('header'); diff --git a/src/Symfony/Component/Notifier/Exception/LengthException.php b/src/Symfony/Component/Notifier/Exception/LengthException.php new file mode 100644 index 0000000000000..fec27f39d8b61 --- /dev/null +++ b/src/Symfony/Component/Notifier/Exception/LengthException.php @@ -0,0 +1,21 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Notifier\Exception; + +/** + * @author Oskar Stark + * + * @experimental in 5.3 + */ +class LengthException extends LogicException +{ +} pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy