Skip to content

Commit d6c1bf4

Browse files
Remove full DSNs from exception messages
1 parent 759554c commit d6c1bf4

File tree

4 files changed

+6
-6
lines changed

4 files changed

+6
-6
lines changed

Store/DoctrineDbalPostgreSqlStore.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ public function __construct($connOrUrl)
5252
$this->conn = $connOrUrl;
5353
} elseif (\is_string($connOrUrl)) {
5454
if (!class_exists(DriverManager::class)) {
55-
throw new InvalidArgumentException(sprintf('Failed to parse the DSN "%s". Try running "composer require doctrine/dbal".', $connOrUrl));
55+
throw new InvalidArgumentException('Failed to parse DSN. Try running "composer require doctrine/dbal".');
5656
}
5757
if (class_exists(DsnParser::class)) {
5858
$params = (new DsnParser([
@@ -274,7 +274,7 @@ private function unlockShared(Key $key): void
274274
private function filterDsn(string $dsn): string
275275
{
276276
if (!str_contains($dsn, '://')) {
277-
throw new InvalidArgumentException(sprintf('String "%s" is not a valid DSN for Doctrine DBAL.', $dsn));
277+
throw new InvalidArgumentException('DSN is invalid for Doctrine DBAL.');
278278
}
279279

280280
[$scheme, $rest] = explode(':', $dsn, 2);

Store/DoctrineDbalStore.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ public function __construct($connOrUrl, array $options = [], float $gcProbabilit
6969
$this->conn = $connOrUrl;
7070
} elseif (\is_string($connOrUrl)) {
7171
if (!class_exists(DriverManager::class)) {
72-
throw new InvalidArgumentException(sprintf('Failed to parse the DSN "%s". Try running "composer require doctrine/dbal".', $connOrUrl));
72+
throw new InvalidArgumentException('Failed to parse the DSN. Try running "composer require doctrine/dbal".');
7373
}
7474
if (class_exists(DsnParser::class)) {
7575
$params = (new DsnParser([

Store/StoreFactory.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ public static function createStore($connection)
7575
case str_starts_with($connection, 'rediss:'):
7676
case str_starts_with($connection, 'memcached:'):
7777
if (!class_exists(AbstractAdapter::class)) {
78-
throw new InvalidArgumentException(sprintf('Unsupported DSN "%s". Try running "composer require symfony/cache".', $connection));
78+
throw new InvalidArgumentException('Unsupported Redis or Memcached DSN. Try running "composer require symfony/cache".');
7979
}
8080
$storeClass = str_starts_with($connection, 'memcached:') ? MemcachedStore::class : RedisStore::class;
8181
$connection = AbstractAdapter::createConnection($connection, ['lazy' => true]);

Store/ZookeeperStore.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,11 +37,11 @@ public function __construct(\Zookeeper $zookeeper)
3737
public static function createConnection(string $dsn): \Zookeeper
3838
{
3939
if (!str_starts_with($dsn, 'zookeeper:')) {
40-
throw new InvalidArgumentException(sprintf('Unsupported DSN: "%s".', $dsn));
40+
throw new InvalidArgumentException('Unsupported DSN for Zookeeper.');
4141
}
4242

4343
if (false === $params = parse_url($dsn)) {
44-
throw new InvalidArgumentException(sprintf('Invalid Zookeeper DSN: "%s".', $dsn));
44+
throw new InvalidArgumentException('Invalid Zookeeper DSN.');
4545
}
4646

4747
$host = $params['host'] ?? '';

0 commit comments

Comments
 (0)