Skip to main content

Exceptions

Every exception the package throws implements Dirthara\Queue\Exception\QueueException, so one catch handles any of them. Each also extends the SPL exception that fits it and carries a context array with the values that describe the failure. Context and messages never contain a message payload or a configuration value.

use Dirthara\Queue\Exception\QueueException;

try {
$handlers->register($type, $handler);
} catch (QueueException $exception) {
$logger->error($exception->getMessage(), $exception->context);
}

Configuration​

These are thrown while an application is being set up, and point to a mistake in its code or configuration.

ExceptionExtendsThrown when
InvalidMessageTypeExceptionInvalidArgumentExceptionA handler or execution policy is registered for an interface, an abstract class, or a name that is not a class or enum.
DuplicateMessageHandlerExceptionInvalidArgumentExceptionA second handler is registered for a message type.
DuplicateMessageExecutionPolicyExceptionInvalidArgumentExceptionA second execution policy is registered for a message type.
DuplicateQueueDriverExceptionInvalidArgumentExceptionA second driver is registered under a name.
InvalidQueueConfigurationExceptionInvalidArgumentExceptionAn option is missing without a default, or has another type than the one read.
InvalidDurationExceptionInvalidArgumentExceptionA duration is negative, or too long to fit in a PHP integer of milliseconds.
InvalidRetryPolicyExceptionInvalidArgumentExceptionAttemptsRetryPolicy is given fewer than one attempt.
InvalidWorkerLimitsExceptionInvalidArgumentExceptionWorkerLimits is given fewer than one message, or a runtime of zero.
InvalidWorkerRunnerExceptionInvalidArgumentExceptionA WorkerRunner is given an idle delay of zero.

Running​

ExceptionExtendsThrown when
MessageSerialisationExceptionRuntimeExceptionA message cannot be serialised, or a payload cannot be deserialised into the message type it records.
MessageHandlerNotFoundExceptionRuntimeExceptionA message's type has no handler.
QueueDriverNotFoundExceptionRuntimeExceptionA queue is created with, or a driver asked for, a name without a driver.
FailedMessageNotFoundExceptionRuntimeExceptionA failed message is retried or forgotten by an id that no failed message has.
DeliveryAlreadySettledExceptionRuntimeExceptionA delivery from the in-memory queue that was already acknowledged, released, or failed is settled again.
WorkerAlreadyRunningExceptionRuntimeExceptionrun() is called on a runner that is already running.
InvalidWorkerResultExceptionInvalidArgumentExceptionA handled, released, or failed WorkerResult is created for an attempt below 1, which points to a queue driver counting attempts wrongly.

A worker does not let a failure to deserialise or handle a message escape: it settles the delivery and reports the failure in its result. What escapes a worker is a failure of the queue itself, such as a delivery that cannot be settled, and those exceptions come from the queue driver.