Skip to content

Commit 31cce53

Browse files
committed
[Messenger] DoctrineTransport - Use InvalidArgumentException instead of TransportException during configuration checks
1 parent 9d682a1 commit 31cce53

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

Tests/Transport/Doctrine/ConnectionTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -213,15 +213,15 @@ public function buildConfigurationProvider()
213213
}
214214

215215
/**
216-
* @expectedException \Symfony\Component\Messenger\Exception\TransportException
216+
* @expectedException \Symfony\Component\Messenger\Exception\InvalidArgumentException
217217
*/
218218
public function testItThrowsAnExceptionIfAnExtraOptionsInDefined()
219219
{
220220
Connection::buildConfiguration('doctrine://default', ['new_option' => 'woops']);
221221
}
222222

223223
/**
224-
* @expectedException \Symfony\Component\Messenger\Exception\TransportException
224+
* @expectedException \Symfony\Component\Messenger\Exception\InvalidArgumentException
225225
*/
226226
public function testItThrowsAnExceptionIfAnExtraOptionsInDefinedInDSN()
227227
{

Transport/Doctrine/Connection.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,13 +87,13 @@ public static function buildConfiguration($dsn, array $options = [])
8787
// check for extra keys in options
8888
$optionsExtraKeys = array_diff(array_keys($options), array_keys($configuration));
8989
if (0 < \count($optionsExtraKeys)) {
90-
throw new TransportException(sprintf('Unknown option found : [%s]. Allowed options are [%s]', implode(', ', $optionsExtraKeys), implode(', ', self::DEFAULT_OPTIONS)));
90+
throw new InvalidArgumentException(sprintf('Unknown option found : [%s]. Allowed options are [%s]', implode(', ', $optionsExtraKeys), implode(', ', self::DEFAULT_OPTIONS)));
9191
}
9292

9393
// check for extra keys in options
9494
$queryExtraKeys = array_diff(array_keys($query), array_keys($configuration));
9595
if (0 < \count($queryExtraKeys)) {
96-
throw new TransportException(sprintf('Unknown option found in DSN: [%s]. Allowed options are [%s]', implode(', ', $queryExtraKeys), implode(', ', self::DEFAULT_OPTIONS)));
96+
throw new InvalidArgumentException(sprintf('Unknown option found in DSN: [%s]. Allowed options are [%s]', implode(', ', $queryExtraKeys), implode(', ', self::DEFAULT_OPTIONS)));
9797
}
9898

9999
return $configuration;

0 commit comments

Comments
 (0)