8000 minor #32608 [Mailer][DX] Improve exception message for unsupported s… · symfony/symfony@7dfc97b · GitHub
[go: up one dir, main page]

Skip to content

Commit 7dfc97b

Browse files
committed
minor #32608 [Mailer][DX] Improve exception message for unsupported scheme (Koc)
This PR was merged into the 4.4 branch. Discussion ---------- [Mailer][DX] Improve exception message for unsupported scheme | Q | A | ------------- | --- | Branch? | 4.4 | Bug fix? | no | New feature? | yes | BC breaks? | no | Deprecations? | no | Tests pass? | waiting for Travis | Fixed tickets | - | License | MIT | Doc PR | - This PR improves exception message for unsupported schemes by providing list of available. Throw something like: ` 'The "foo" scheme is not supported for mailer "mailgun". Supported schemes are: "api", "http", "smtp".'` Commits ------- 8c24a53 [Mailer][DX] Improve exception message for unsupported scheme
2 parents 0d8f5fe + 8c24a53 commit 7dfc97b

18 files changed

+47
-19
lines changed

src/Symfony/Component/Mailer/Bridge/Amazon/Factory/SesTransportFactory.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ public function create(Dsn $dsn): TransportInterface
4141
return new Amazon\Smtp\SesTransport($user, $password, $region, $this->dispatcher, $this->logger);
4242
}
4343

44-
throw new UnsupportedSchemeException($dsn);
44+
throw new UnsupportedSchemeException($dsn, ['api', 'http', 'smtp']);
4545
}
4646

4747
public function supports(Dsn $dsn): bool

src/Symfony/Component/Mailer/Bridge/Amazon/Tests/Factory/SesTransportFactoryTest.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,10 @@ public function createProvider(): iterable
8686

8787
public function unsupportedSchemeProvider(): iterable
8888
{
89-
yield [new Dsn('foo', 'ses', self::USER, self::PASSWORD)];
89+
yield [
90+
new Dsn('foo', 'ses', self::USER, self::PASSWORD),
91+
'The "foo" scheme is not supported for mailer "ses". Supported schemes are: "api", "http", "smtp".',
92+
];
9093
}
9194

9295
public function incompleteDsnProvider(): iterable

src/Symfony/Component/Mailer/Bridge/Google/Factory/GmailTransportFactory.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ public function create(Dsn $dsn): TransportInterface
2828
return new GmailTransport($this->getUser($dsn), $this->getPassword($dsn), $this->dispatcher, $this->logger);
2929
}
3030

31-
throw new UnsupportedSchemeException($dsn);
31+
throw new UnsupportedSchemeException($dsn, ['smtp']);
3232
}
3333

3434
public function supports(Dsn $dsn): bool

src/Symfony/Component/Mailer/Bridge/Google/Tests/Factory/GmailTransportFactoryTest.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,10 @@ public function createProvider(): iterable
3838

3939
public function unsupportedSchemeProvider(): iterable
4040
{
41-
yield [new Dsn('http', 'gmail', self::USER, self::PASSWORD)];
41+
yield [
42+
new Dsn('foo', 'gmail', self::USER, self::PASSWORD),
43+
'The "foo" scheme is not supported for mailer "gmail". Supported schemes are: "smtp".',
44+
];
4245
}
4346

4447
public function incompleteDsnProvider(): iterable

src/Symfony/Component/Mailer/Bridge/Mailchimp/Factory/MandrillTransportFactory.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ public function create(Dsn $dsn): TransportInterface
4141
return new Mailchimp\Smtp\MandrillTransport($user, $password, $this->dispatcher, $this->logger);
4242
}
4343

44-
throw new UnsupportedSchemeException($dsn);
44+
throw new UnsupportedSchemeException($dsn, ['api', 'http', 'smtp']);
4545
}
4646

4747
public function supports(Dsn $dsn): bool

src/Symfony/Component/Mailer/Bridge/Mailchimp/Tests/Factory/MandrillTransportFactoryTest.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,10 @@ public function createProvider(): iterable
7171

7272
public function unsupportedSchemeProvider(): iterable
7373
{
74-
yield [new Dsn('foo', 'mandrill', self::USER)];
74+
yield [
75+
new Dsn('foo', 'mandrill', self::USER),
76+
'The "foo" scheme is not supported for mailer "mandrill". Supported schemes are: "api", "http", "smtp".',
77+
];
7578
}
7679

7780
public function incompleteDsnProvider(): iterable

src/Symfony/Component/Mailer/Bridge/Mailgun/Factory/MailgunTransportFactory.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ public function create(Dsn $dsn): TransportInterface
4141
return new Mailgun\Smtp\MailgunTransport($user, $password, $region, $this->dispatcher, $this->logger);
4242
}
4343

44-
throw new UnsupportedSchemeException($dsn);
44+
throw new UnsupportedSchemeException($dsn, ['api', 'http', 'smtp']);
4545
}
4646

4747
public function supports(Dsn $dsn): bool

src/Symfony/Component/Mailer/Bridge/Mailgun/Tests/Factory/MailgunTransportFactoryTest.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,10 @@ public function createProvider(): iterable
7676

7777
public function unsupportedSchemeProvider(): iterable
7878
{
79-
yield [new Dsn('foo', 'mailgun', self::USER, self::PASSWORD)];
79+
yield [
80+
new Dsn('foo', 'mailgun', self::USER, self::PASSWORD),
81+
'The "foo" scheme is not supported for mailer "mailgun". Supported schemes are: "api", "http", "smtp".',
82+
];
8083
}
8184

8285
public function incompleteDsnProvider(): iterable

src/Symfony/Component/Mailer/Bridge/Postmark/Factory/PostmarkTransportFactory.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ public function create(Dsn $dsn): TransportInterface
3535
return new Postmark\Smtp\PostmarkTransport($user, $this->dispatcher, $this->logger);
3636
}
3737

38-
throw new UnsupportedSchemeException($dsn);
38+
throw new UnsupportedSchemeException($dsn, ['api', 'smtp']);
3939
}
4040

4141
public function supports(Dsn $dsn): bool

src/Symfony/Component/Mailer/Bridge/Postmark/Tests/Factory/PostmarkTransportFactoryTest.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,10 @@ public function createProvider(): iterable
6060

6161
public function unsupportedSchemeProvider(): iterable
6262
{
63-
yield [new Dsn('foo', 'postmark', self::USER)];
63+
yield [
64+
new Dsn('foo', 'postmark', self::USER),
65+
'The "foo" scheme is not supported for mailer "postmark". Supported schemes are: "api", "smtp".',
66+
];
6467
}
6568

6669
public function incompleteDsnProvider(): iterable

0 commit comments

Comments
 (0)
0