Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork9.6k
[Mailer][Transport] Allow exception logging forRoundRobinTransport
mailer#60110
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
base:7.4
Are you sure you want to change the base?
Uh oh!
There was an error while loading.Please reload this page.
Conversation
This comment was marked as outdated.
This comment was marked as outdated.
Injecting an exception handler callback looks uncommon to me. This looks like a use case for injecting a logger and performing some logging. |
40b9b2c
to4de5ed8
CompareThanks for your suggestion! While I figured a callback would allow for more flexibility, I do agree that a logger is probably a more standard way of approaching this. I've adjusted to inject a |
RoundRobinTransport
mailer
The
RoundRobinTransport
class (and by extension theFailoverTransport
class) allow one to mail using different mail transports, with automatic failover in case a mailer fails. In case of such a failure, exceptions are caught (and grouped in case of multiple failures) and the next transport is attempted. This ensures that as long as one transport succeeds, the mail will be delivered.However, the current way of exception handling also means that exceptions on failing transports will never bubble up, unless all of them fail at once. This means that in case of a prolonged failure of a transport, e.g. due to misconfiguration, the only way to detect such a failure is by noting that a intended mailer is never sending mail, rather then be warned by actual exceptions of your application. If this is not detected, then one will only discover once all senders are failing, that one of them might have been failing all of the time already.
To allow one to be notified of all exceptions happening within the handling of sending a mail, I propose to add an
$exceptionHandler
property to the class, that would allow one to manually add a callback for handling exceptions in an additional way. For example, this would allow one to manually send the exception to some service in a structured manner, so one can address the failing transport, while sending would still continue properly as long as there's still a succeeding transport left.