10000 [Messenger] Display a nice error when connection fail · symfony/symfony@eac014f · GitHub
[go: up one dir, main page]

Skip to content

Commit eac014f

Browse files
committed
[Messenger] Display a nice error when connection fail
1 parent 0762d2d commit eac014f

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

src/Symfony/Component/Messenger/Transport/AmqpExt/Connection.php

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -199,10 +199,14 @@ public function channel(): \AMQPChannel
199199
$connection = $this->amqpFactory->createConnection($this->connectionCredentials);
200200
$connectMethod = 'true' === ($this->connectionCredentials['persistent'] ?? 'false') ? 'pconnect' : 'connect';
201201

202-
if (false === $connection->{$connectMethod}()) {
203-
throw new \AMQPException('Could not connect to the AMQP server. Please verify the provided DSN.');
204-
}
202+
try {
203+
$connection->{$connectMethod}();
204+
} catch (\AMQPConnectionException $e) {
205+
$credentials = $this->connectionCredentials;
206+
$credentials['password'] = '********';
205207

208+
throw new \AMQPException(sprintf('Could not connect to the AMQP server. Please verify the provided DSN. (%s)', json_encode($credentials)), 0, $e);
209+
}
206210
$this->amqpChannel = $this->amqpFactory->createChannel($connection);
207211
}
208212

0 commit comments

Comments
 (0)
0