Skip to content

Commit 674807e

Browse files
committed
TASK: Add helpful exception when the queue table can't be read from
1 parent cdb71dc commit 674807e

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

Classes/Queue/DoctrineQueue.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
use Doctrine\Common\Persistence\ObjectManager as DoctrineObjectManager;
1515
use Doctrine\DBAL\Connection;
1616
use Doctrine\DBAL\DriverManager;
17+
use Doctrine\DBAL\Exception\TableNotFoundException;
1718
use Doctrine\ORM\EntityManager as DoctrineEntityManager;
1819
use Flowpack\JobQueue\Common\Queue\Message;
1920
use Flowpack\JobQueue\Common\Queue\QueueInterface;
@@ -175,7 +176,11 @@ protected function reserveMessage($timeout = null)
175176
}
176177
$startTime = time();
177178
do {
178-
$row = $this->connection->fetchAssoc("SELECT * FROM {$this->connection->quoteIdentifier($this->tableName)} WHERE state = 'ready' AND {$this->getScheduledQueryConstraint()} LIMIT 1");
179+
try {
180+
$row = $this->connection->fetchAssoc("SELECT * FROM {$this->connection->quoteIdentifier($this->tableName)} WHERE state = 'ready' AND {$this->getScheduledQueryConstraint()} LIMIT 1");
181+
} catch (TableNotFoundException $exception) {
182+
throw new \RuntimeException(sprintf('The queue table "%s" could not be found. Did you run ./flow queue:setup "%s"?', $this->tableName, $this->name), 1469117906, $exception);
183+
}
179184
if ($row !== false) {
180185
$numberOfUpdatedRows = $this->connection->executeUpdate("UPDATE {$this->connection->quoteIdentifier($this->tableName)} SET state = 'reserved' WHERE id = :id AND state = 'ready' AND {$this->getScheduledQueryConstraint()}", ['id' => (integer)$row['id']]);
181186
if ($numberOfUpdatedRows === 1) {

0 commit comments

Comments
 (0)