File tree Expand file tree Collapse file tree 1 file changed +12
-1
lines changed Expand file tree Collapse file tree 1 file changed +12
-1
lines changed Original file line number Diff line number Diff line change 1515use Symfony \Component \EventDispatcher \Event ;
1616use Symfony \Component \EventDispatcher \LegacyEventDispatcherProxy ;
1717use Symfony \Component \Mailer \Event \MessageEvent ;
18+ use Symfony \Component \Mailer \Exception \TransportExceptionInterface ;
1819use Symfony \Component \Mailer \Messenger \SendEmailMessage ;
1920use Symfony \Component \Mailer \Transport \TransportInterface ;
21+ use Symfony \Component \Messenger \Exception \HandlerFailedException ;
2022use Symfony \Component \Messenger \MessageBusInterface ;
2123use Symfony \Component \Mime \RawMessage ;
2224use Symfony \Contracts \EventDispatcher \EventDispatcherInterface as SymfonyEventDispatcherInterface ;
@@ -52,6 +54,15 @@ public function send(RawMessage $message, Envelope $envelope = null): void
5254 $ this ->dispatcher ->dispatch ($ event );
5355 }
5456
55- $ this ->bus ->dispatch (new SendEmailMessage ($ message , $ envelope ));
57+ try {
58+ $ this ->bus ->dispatch (new SendEmailMessage ($ message , $ envelope ));
59+ } catch (HandlerFailedException $ e ) {
60+ foreach ($ e ->getNestedExceptions () as $ nested ) {
61+ if ($ nested instanceof TransportExceptionInterface) {
62+ throw $ nested ;
63+ }
64+ }
65+ throw $ e ;
66+ }
5667 }
5768}
You can’t perform that action at this time.
0 commit comments