Extract unrecoverable exception to interface

This commit is contained in:
Tobias Schultze 2019-06-24 03:47:45 +01:00
parent b68a6b3e16
commit 6a2f4dc67a
8 changed files with 35 additions and 12 deletions

View File

@ -17,7 +17,7 @@ namespace Symfony\Component\Messenger\Exception;
*
* @author Tobias Nyholm <tobias.nyholm@gmail.com>
*/
class DelayedMessageHandlingException extends \RuntimeException implements ExceptionInterface
class DelayedMessageHandlingException extends RuntimeException
{
private $exceptions;

View File

@ -16,6 +16,6 @@ namespace Symfony\Component\Messenger\Exception;
*
* @experimental in 4.3
*/
class MessageDecodingFailedException extends \InvalidArgumentException implements ExceptionInterface
class MessageDecodingFailedException extends InvalidArgumentException
{
}

View File

@ -16,6 +16,6 @@ namespace Symfony\Component\Messenger\Exception;
*
* @experimental in 4.3
*/
class NoHandlerForMessageException extends \LogicException implements ExceptionInterface
class NoHandlerForMessageException extends LogicException
{
}

View File

@ -16,6 +16,6 @@ namespace Symfony\Component\Messenger\Exception;
*
* @experimental in 4.3
*/
class UnknownSenderException extends \InvalidArgumentException implements ExceptionInterface
class UnknownSenderException extends InvalidArgumentException
{
}

View File

@ -0,0 +1,26 @@
<?php
/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Component\Messenger\Exception;
/**
* Marker interface for exceptions to indicate that handling a message will continue to fail.
*
* If something goes wrong while handling a message that's received from a transport
* and the message should not be retried, a handler can throw such an exception.
*
* @author Tobias Schultze <http://tobion.de>
*
* @experimental in 4.3
*/
interface UnrecoverableExceptionInterface extends \Throwable
{
}

View File

@ -12,15 +12,12 @@
namespace Symfony\Component\Messenger\Exception;
/**
* Thrown while handling a message to indicate that handling will continue to fail.
*
* If something goes wrong while handling a message that's received from a transport
* and the message should not be retried, a handler can throw this exception.
* A concrete implementation of UnrecoverableExceptionInterface that can be used directly.
*
* @author Frederic Bouchery <frederic@bouchery.fr>
*
* @experimental in 4.3
*/
class UnrecoverableMessageHandlingException extends RuntimeException
class UnrecoverableMessageHandlingException extends RuntimeException implements UnrecoverableExceptionInterface
{
}

View File

@ -18,7 +18,7 @@ use Symfony\Component\Validator\ConstraintViolationListInterface;
*
* @experimental in 4.3
*/
class ValidationFailedException extends \RuntimeException implements ExceptionInterface
class ValidationFailedException extends RuntimeException
{
private $violations;
private $violatingMessage;

View File

@ -17,7 +17,7 @@ use Symfony\Component\Messenger\Event\WorkerMessageHandledEvent;
use Symfony\Component\Messenger\Event\WorkerMessageReceivedEvent;
use Symfony\Component\Messenger\Event\WorkerStoppedEvent;
use Symfony\Component\Messenger\Exception\HandlerFailedException;
use Symfony\Component\Messenger\Exception\UnrecoverableMessageHandlingException;
use Symfony\Component\Messenger\Exception\UnrecoverableExceptionInterface;
use Symfony\Component\Messenger\Retry\RetryStrategyInterface;
use Symfony\Component\Messenger\Stamp\DelayStamp;
use Symfony\Component\Messenger\Stamp\ReceivedStamp;
@ -191,7 +191,7 @@ class Worker implements WorkerInterface
private function shouldRetry(\Throwable $e, Envelope $envelope, RetryStrategyInterface $retryStrategy): bool
{
if ($e instanceof UnrecoverableMessageHandlingException) {
if ($e instanceof UnrecoverableExceptionInterface) {
return false;
}