feature #30583 [Messenger] Display a nice error when connection fail (lyrixx)
This PR was merged into the 4.3-dev branch.
Discussion
----------
[Messenger] Display a nice error when connection fail
| Q | A
| ------------- | ---
| Branch? | master
| Bug fix? | no
| New feature? | kind of
| BC breaks? | no
| Deprecations? | no
| Tests pass? | yes
| Fixed tickets |
| License | MIT
| Doc PR |
### Before:
![image](https://user-images.githubusercontent.com/408368/54469293-6bc12f80-4796-11e9-897c-f07504132214.png)
### Now:
![image](https://user-images.githubusercontent.com/408368/54469287-5c41e680-4796-11e9-80ac-692899693542.png)
Commits
-------
eac014febd
[Messenger] Display a nice error when connection fail
This commit is contained in:
commit
0c6f0b4a44
@ -199,10 +199,14 @@ class Connection
|
|||||||
$connection = $this->amqpFactory->createConnection($this->connectionCredentials);
|
$connection = $this->amqpFactory->createConnection($this->connectionCredentials);
|
||||||
$connectMethod = 'true' === ($this->connectionCredentials['persistent'] ?? 'false') ? 'pconnect' : 'connect';
|
$connectMethod = 'true' === ($this->connectionCredentials['persistent'] ?? 'false') ? 'pconnect' : 'connect';
|
||||||
|
|
||||||
if (false === $connection->{$connectMethod}()) {
|
try {
|
||||||
throw new \AMQPException('Could not connect to the AMQP server. Please verify the provided DSN.');
|
$connection->{$connectMethod}();
|
||||||
}
|
} catch (\AMQPConnectionException $e) {
|
||||||
|
$credentials = $this->connectionCredentials;
|
||||||
|
$credentials['password'] = '********';
|
||||||
|
|
||||||
|
throw new \AMQPException(sprintf('Could not connect to the AMQP server. Please verify the provided DSN. (%s)', json_encode($credentials)), 0, $e);
|
||||||
|
}
|
||||||
$this->amqpChannel = $this->amqpFactory->createChannel($connection);
|
$this->amqpChannel = $this->amqpFactory->createChannel($connection);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user