Skip to content

Commit 1ebc259

Browse files
committed
minor #51311 [Messenger] helpful exception when requesting an AMQP queue that is not configured (dbu)
This PR was squashed before being merged into the 7.1 branch. Discussion ---------- [Messenger] helpful exception when requesting an AMQP queue that is not configured without this check, running `messenger:consume --queue=notexisting` gives an "undefined array key" PHP error with no helpful context at all. | Q | A | ------------- | --- | Branch? | 6.4 | Bug fix? | no | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | - | License | MIT | Doc PR | - just struggled a bit to figure out what the problem was, until i realized my typo in the queue name on the cli... this could also be added to older versions of symfony as its not a new feature but a sanity check that replaces a PHP error with a meaningful exception. happy to adjust my pull request if you want me to. Commits ------- 0d0749efcf [Messenger] helpful exception when requesting an AMQP queue that is not configured
2 parents 295ddf3 + 9c9222f commit 1ebc259

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

Transport/Connection.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -510,6 +510,9 @@ public function channel(): \AMQPChannel
510510
public function queue(string $queueName): \AMQPQueue
511511
{
512512
if (!isset($this->amqpQueues[$queueName])) {
513+
if (!\array_key_exists($queueName, $this->queuesOptions)) {
514+
throw new InvalidArgumentException(sprintf('Exchange "%s" does not have a queue named "%s", known queues are "%s"', $this->exchangeOptions['name'], $queueName, implode('", "', array_keys($this->queuesOptions))));
515+
}
513516
$queueConfig = $this->queuesOptions[$queueName];
514517

515518
$amqpQueue = $this->amqpFactory->createQueue($this->channel());

0 commit comments

Comments
 (0)