-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[Mailer] Make sure Http TransportException is not leaking #42184
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 our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Mailer] Make sure Http TransportException is not leaking #42184
Conversation
82a061e
to
f888d56
Compare
One minor question, why not against |
src/Symfony/Component/Mailer/Bridge/Mailgun/Transport/MailgunApiTransport.php
Outdated
Show resolved
Hide resolved
} catch (TransportExceptionInterface $e) { | ||
throw new HttpTransportException('Could not reach the remote Mailgun server.', $response, 0, $e); | ||
} | ||
|
||
if (200 !== $response->getStatusCode()) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd wrap the call to getStatusCode
and toArray
in the same try/catch (same everywhere)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure. I will but why? This will never throw TransportExceptionInterface
if I first get the body.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd say to make things easy to reason about and consistent (some places were calling getStatusCode before toArray/getContent)
f888d56
to
1681bc1
Compare
The PR is updated. I've targeted 4.4 and made sure we get both status code and body inside the try/catch |
Thank you @Nyholm. |
We dont want the mailer to throw exceptions from the http-client component. This will make sure to catch such exceptions and rethrow the proper HttpTransportException from the Mailer component.