Skip to content

Commit 0f4772d

Browse files
Merge branch '5.4' into 6.0
* 5.4: [Validator] Multi decimal to alpha for CssColor validator [Console] Fix null handling in formatAndWrap() MailerInterface: failed exception contract when enabling messenger add nonces to profiler
2 parents 81b0678 + f6e927e commit 0f4772d

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

Mailer.php

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,10 @@
1313

1414
use Psr\EventDispatcher\EventDispatcherInterface;
1515
use Symfony\Component\Mailer\Event\MessageEvent;
16+
use Symfony\Component\Mailer\Exception\TransportExceptionInterface;
1617
use Symfony\Component\Mailer\Messenger\SendEmailMessage;
1718
use Symfony\Component\Mailer\Transport\TransportInterface;
19+
use Symfony\Component\Messenger\Exception\HandlerFailedException;
1820
use Symfony\Component\Messenger\MessageBusInterface;
1921
use Symfony\Component\Mime\RawMessage;
2022

@@ -49,6 +51,15 @@ public function send(RawMessage $message, Envelope $envelope = null): void
4951
$this->dispatcher->dispatch($event);
5052
}
5153

52-
$this->bus->dispatch(new SendEmailMessage($message, $envelope));
54+
try {
55+
$this->bus->dispatch(new SendEmailMessage($message, $envelope));
56+
} catch (HandlerFailedException $e) {
57+
foreach ($e->getNestedExceptions() as $nested) {
58+
if ($nested instanceof TransportExceptionInterface) {
59+
throw $nested;
60+
}
61+
}
62+
throw $e;
63+
}
5364
}
5465
}

0 commit comments

Comments
 (0)