File tree Expand file tree Collapse file tree 4 files changed +33
-7
lines changed
src/Symfony/Component/Notifier Expand file tree Collapse file tree 4 files changed +33
-7
lines changed Original file line number Diff line number Diff line change 14
14
use PHPUnit \Framework \TestCase ;
15
15
use Symfony \Component \HttpClient \MockHttpClient ;
16
16
use Symfony \Component \Notifier \Bridge \Discord \DiscordTransport ;
17
+ use Symfony \Component \Notifier \Exception \LengthException ;
17
18
use Symfony \Component \Notifier \Exception \LogicException ;
18
19
use Symfony \Component \Notifier \Exception \TransportException ;
19
20
use Symfony \Component \Notifier \Exception \UnsupportedMessageTypeException ;
@@ -55,7 +56,7 @@ public function testSendChatMessageWithMoreThan2000CharsThrowsLogicException()
55
56
{
56
57
$ transport = new DiscordTransport ('testToken ' , 'testChannel ' , $ this ->createMock (HttpClientInterface::class));
57
58
58
- $ this ->expectException (LogicException ::class);
59
+ $ this ->expectException (LengthException ::class);
59
60
$ this ->expectExceptionMessage ('The subject length of a Discord message must not exceed 2000 characters. ' );
60
61
61
62
$ transport ->send (new ChatMessage (str_repeat ('d ' , 2001 )));
Original file line number Diff line number Diff line change 11
11
12
12
namespace Symfony \Component \Notifier \Bridge \Slack \Block ;
13
13
14
- use Symfony \Component \Notifier \Exception \LogicException ;
14
+ use Symfony \Component \Notifier \Exception \LengthException ;
15
15
16
16
/**
17
17
* @author Tomas Norkūnas <norkunas.tom@gmail.com>
@@ -26,7 +26,7 @@ final class SlackHeaderBlock extends AbstractSlackBlock
26
26
public function __construct (string $ text )
27
27
{
28
28
if (\strlen ($ text ) > self ::TEXT_LIMIT ) {
29
- throw new LogicException (sprintf ('Maximum length for the text is %d characters. ' , self ::TEXT_LIMIT ));
29
+ throw new LengthException (sprintf ('Maximum length for the text is %d characters. ' , self ::TEXT_LIMIT ));
30
30
}
31
31
32
32
$ this ->options = [
@@ -41,7 +41,7 @@ public function __construct(string $text)
41
41
public function id (string $ id ): self
42
42
{
43
43
if (\strlen ($ id ) > self ::ID_LIMIT ) {
44
- throw new LogicException (sprintf ('Maximum length for the block id is %d characters. ' , self ::ID_LIMIT ));
44
+ throw new LengthException (sprintf ('Maximum length for the block id is %d characters. ' , self ::ID_LIMIT ));
45
45
}
46
46
47
47
$ this ->options ['block_id ' ] = $ id ;
Original file line number Diff line number Diff line change 13
13
14
14
use PHPUnit \Framework \TestCase ;
15
15
use Symfony \Component \Notifier \Bridge \Slack \Block \SlackHeaderBlock ;
16
- use Symfony \Component \Notifier \Exception \LogicException ;
16
+ use Symfony \Component \Notifier \Exception \LengthException ;
17
17
18
18
final class SlackHeaderBlockTest extends TestCase
19
19
{
@@ -34,15 +34,15 @@ public function testCanBeInstantiated(): void
34
34
35
35
public function testThrowsWhenTextExceedsCharacterLimit (): void
36
36
{
37
- $ this ->expectException (LogicException ::class);
37
+ $ this ->expectException (LengthException ::class);
38
38
$ this ->expectExceptionMessage ('Maximum length for the text is 150 characters. ' );
39
39
40
40
new SlackHeaderBlock (str_repeat ('h ' , 151 ));
41
41
}
42
42
43
43
public function testThrowsWhenBlockIdExceedsCharacterLimit (): void
44
44
{
45
- $ this ->expectException (LogicException ::class);
45
+ $ this ->expectException (LengthException ::class);
46
46
$ this ->expectExceptionMessage ('Maximum length for the block id is 255 characters. ' );
47
47
48
48
$ header = new SlackHeaderBlock ('header ' );
Original file line number Diff line number Diff line change
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
+ /**
15
+ * @author Oskar Stark <oskarstark@googlemail.com>
16
+ *
17
+ * @experimental in 5.3
18
+ */
19
+ class LengthException extends LogicException
20
+ {
21
+ public function __construct (string $ message )
22
+ {
23
+ parent ::__construct ($ message );
24
+ }
25
+ }
You can’t perform that action at this time.
0 commit comments