Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit c73c919

Browse files
committed
[Messenger] Display a nice error when connection fail
1 parent 18cd342 commit c73c919

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

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

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

204-
if (false === $connection->{$connectMethod}()) {
205-
throw new \AMQPException('Could not connect to the AMQP server. Please verify the provided DSN.');
204+
try {
205+
$connection->{$connectMethod}();
206+
} catch (\AMQPConnectionException $e) {
207+
throw new \AMQPException(sprintf('Could not connect to the AMQP server. Please verify the provided DSN. (%s)', json_encode($this->connectionCredentials)), 0, $e);
206208
}
207-
208209
$this->amqpChannel = $this->amqpFactory->createChannel($connection);
209210
}
210211

0 commit comments

Comments
 (0)