Skip to content

Commit eefcb33

Browse files
committed
feature #32896 [Mailer] added debug info to TransportExceptionInterface (fabpot)
This PR was merged into the 4.4 branch. Discussion ---------- [Mailer] added debug info to TransportExceptionInterface | Q | A | ------------- | --- | Branch? | 4.4 | Bug fix? | no | New feature? | yes | BC breaks? | no <!-- see https://symfony.com/bc --> | Deprecations? | no <!-- please update UPGRADE-*.md and src/**/CHANGELOG.md files --> | Tests pass? | yes <!-- please add some, will be required by reviewers --> | Fixed tickets | n/a | License | MIT | Doc PR | ~ In 4.4, you can get the debug information for the SMTP/HTTP data via `$message->getDebug()` (see #32583). But the data are probably even more important when there is an exception. That's what I implemented in this PR. Commits ------- 39ebb84 [Mailer] added debug info to TransportExceptionInterface
2 parents 87458fc + 39ebb84 commit eefcb33

File tree

3 files changed

+18
-1
lines changed

3 files changed

+18
-1
lines changed

src/Symfony/Component/Mailer/Exception/TransportException.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,15 @@
1616
*/
1717
class TransportException extends RuntimeException implements TransportExceptionInterface
1818
{
19+
private $debug = '';
20+
21+
public function getDebug(): string
22+
{
23+
return $this->debug;
24+
}
25+
26+
public function appendDebug(string $debug): void
27+
{
28+
$this->debug .= $debug;
29+
}
1930
}

src/Symfony/Component/Mailer/Exception/TransportExceptionInterface.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,7 @@
1616
*/
1717
interface TransportExceptionInterface extends ExceptionInterface
1818
{
19+
public function getDebug(): string;
20+
21+
public function appendDebug(string $debug): void;
1922
}

src/Symfony/Component/Mailer/Transport/Smtp/SmtpTransport.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,8 +161,11 @@ protected function doSend(SentMessage $message): void
161161
}
162162
$this->stream->flush();
163163
$this->executeCommand("\r\n.\r\n", [250]);
164-
} finally {
165164
$message->appendDebug($this->stream->getDebug());
165+
} catch (TransportExceptionInterface $e) {
166+
$e->appendDebug($this->stream->getDebug());
167+
168+
throw $e;
166169
}
167170
}
168171

0 commit comments

Comments
 (0)