Skip to content

Commit 5ca8a76

Browse files
Remove full DSNs from exception messages
1 parent 6330cd4 commit 5ca8a76

File tree

4 files changed

+10
-10
lines changed

4 files changed

+10
-10
lines changed

Tests/Transport/DsnTest.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -92,17 +92,17 @@ public static function invalidDsnProvider(): iterable
9292
{
9393
yield [
9494
'some://',
95-
'The "some://" mailer DSN is invalid.',
95+
'The mailer DSN is invalid.',
9696
];
9797

9898
yield [
9999
'//sendmail',
100-
'The "//sendmail" mailer DSN must contain a scheme.',
100+
'The mailer DSN must contain a scheme.',
101101
];
102102

103103
yield [
104104
'file:///some/path',
105-
'The "file:///some/path" mailer DSN must contain a host (use "default" by default).',
105+
'The mailer DSN must contain a host (use "default" by default).',
106106
];
107107
}
108108
}

Tests/TransportTest.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -90,11 +90,11 @@ public function testFromWrongString(string $dsn, string $error)
9090

9191
public static function fromWrongStringProvider(): iterable
9292
{
93-
yield 'garbage at the end' => ['dummy://a some garbage here', 'The DSN has some garbage at the end: " some garbage here".'];
93+
yield 'garbage at the end' => ['dummy://a some garbage here', 'The mailer DSN has some garbage at the end.'];
9494

95-
yield 'not a valid DSN' => ['something not a dsn', 'The "something" mailer DSN must contain a scheme.'];
95+
yield 'not a valid DSN' => ['something not a dsn', 'The mailer DSN must contain a scheme.'];
9696

97-
yield 'failover not closed' => ['failover(dummy://a', 'The "(dummy://a" mailer DSN must contain a scheme.'];
97+
yield 'failover not closed' => ['failover(dummy://a', 'The mailer DSN must contain a scheme.'];
9898

9999
yield 'not a valid keyword' => ['foobar(dummy://a)', 'The "foobar" keyword is not valid (valid ones are "failover", "roundrobin")'];
100100
}

Transport.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ public function fromString(string $dsn): TransportInterface
112112
{
113113
[$transport, $offset] = $this->parseDsn($dsn);
114114
if ($offset !== \strlen($dsn)) {
115-
throw new InvalidArgumentException(sprintf('The DSN has some garbage at the end: "%s".', substr($dsn, $offset)));
115+
throw new InvalidArgumentException('The mailer DSN has some garbage at the end.');
116116
}
117117

118118
return $transport;

Transport/Dsn.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,15 +38,15 @@ public function __construct(string $scheme, string $host, string $user = null, s
3838
public static function fromString(string $dsn): self
3939
{
4040
if (false === $parsedDsn = parse_url($dsn)) {
41-
throw new InvalidArgumentException(sprintf('The "%s" mailer DSN is invalid.', $dsn));
41+
throw new InvalidArgumentException('The mailer DSN is invalid.');
4242
}
4343

4444
if (!isset($parsedDsn['scheme'])) {
45-
throw new InvalidArgumentException(sprintf('The "%s" mailer DSN must contain a scheme.', $dsn));
45+
throw new InvalidArgumentException('The mailer DSN must contain a scheme.');
4646
}
4747

4848
if (!isset($parsedDsn['host'])) {
49-
throw new InvalidArgumentException(sprintf('The "%s" mailer DSN must contain a host (use "default" by default).', $dsn));
49+
throw new InvalidArgumentException('The mailer DSN must contain a host (use "default" by default).');
5050
}
5151

5252
$user = '' !== ($parsedDsn['user'] ?? '') ? urldecode($parsedDsn['user']) : null;

0 commit comments

Comments
 (0)