Skip to content

Commit 072a2dd

Browse files
OskarStarkjderusse
authored andcommitted
[Notifier] [DX] UnsupportedMessageTypeException for notifier transports
1 parent 58923e0 commit 072a2dd

File tree

2 files changed

+35
-0
lines changed

2 files changed

+35
-0
lines changed
Lines 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+
$transport,
28+
$supported,
29+
get_debug_type($given)
30+
);
31+
32+
parent::__construct($message);
33+
}
34+
}

Transport/TransportInterface.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
namespace Symfony\Component\Notifier\Transport;
1313

1414
use Symfony\Component\Notifier\Exception\TransportExceptionInterface;
15+
use Symfony\Component\Notifier\Exception\UnsupportedMessageTypeException;
1516
use Symfony\Component\Notifier\Message\MessageInterface;
1617
use Symfony\Component\Notifier\Message\SentMessage;
1718

0 commit comments

Comments
 (0)