Skip to content

Commit

Permalink
Remove full DSNs from exception messages
Browse files Browse the repository at this point in the history
  • Loading branch information
nicolas-grekas committed Nov 3, 2023
1 parent 759554c commit d6c1bf4
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 6 deletions.
4 changes: 2 additions & 2 deletions Store/DoctrineDbalPostgreSqlStore.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ public function __construct($connOrUrl)
$this->conn = $connOrUrl;
} elseif (\is_string($connOrUrl)) {
if (!class_exists(DriverManager::class)) {
throw new InvalidArgumentException(sprintf('Failed to parse the DSN "%s". Try running "composer require doctrine/dbal".', $connOrUrl));
throw new InvalidArgumentException('Failed to parse DSN. Try running "composer require doctrine/dbal".');
}
if (class_exists(DsnParser::class)) {
$params = (new DsnParser([
Expand Down Expand Up @@ -274,7 +274,7 @@ private function unlockShared(Key $key): void
private function filterDsn(string $dsn): string
{
if (!str_contains($dsn, '://')) {
throw new InvalidArgumentException(sprintf('String "%s" is not a valid DSN for Doctrine DBAL.', $dsn));
throw new InvalidArgumentException('DSN is invalid for Doctrine DBAL.');
}

[$scheme, $rest] = explode(':', $dsn, 2);
Expand Down
2 changes: 1 addition & 1 deletion Store/DoctrineDbalStore.php
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ public function __construct($connOrUrl, array $options = [], float $gcProbabilit
$this->conn = $connOrUrl;
} elseif (\is_string($connOrUrl)) {
if (!class_exists(DriverManager::class)) {
throw new InvalidArgumentException(sprintf('Failed to parse the DSN "%s". Try running "composer require doctrine/dbal".', $connOrUrl));
throw new InvalidArgumentException('Failed to parse the DSN. Try running "composer require doctrine/dbal".');
}
if (class_exists(DsnParser::class)) {
$params = (new DsnParser([
Expand Down
2 changes: 1 addition & 1 deletion Store/StoreFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ public static function createStore($connection)
case str_starts_with($connection, 'rediss:'):
case str_starts_with($connection, 'memcached:'):
if (!class_exists(AbstractAdapter::class)) {
throw new InvalidArgumentException(sprintf('Unsupported DSN "%s". Try running "composer require symfony/cache".', $connection));
throw new InvalidArgumentException('Unsupported Redis or Memcached DSN. Try running "composer require symfony/cache".');
}
$storeClass = str_starts_with($connection, 'memcached:') ? MemcachedStore::class : RedisStore::class;
$connection = AbstractAdapter::createConnection($connection, ['lazy' => true]);
Expand Down
4 changes: 2 additions & 2 deletions Store/ZookeeperStore.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,11 @@ public function __construct(\Zookeeper $zookeeper)
public static function createConnection(string $dsn): \Zookeeper
{
if (!str_starts_with($dsn, 'zookeeper:')) {
throw new InvalidArgumentException(sprintf('Unsupported DSN: "%s".', $dsn));
throw new InvalidArgumentException('Unsupported DSN for Zookeeper.');
}

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

$host = $params['host'] ?? '';
Expand Down

0 comments on commit d6c1bf4

Please sign in to comment.