Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 7f9dad1

Browse filesBrowse files
committed
minor #32145 [Messenger] Extract unrecoverable exception to interface (Tobion)
This PR was merged into the 4.3 branch. Discussion ---------- [Messenger] Extract unrecoverable exception to interface | Q | A | ------------- | --- | Branch? | 4.3 | Bug fix? | no | New feature? | no <!-- please update src/**/CHANGELOG.md files --> | BC breaks? | no <!-- see https://symfony.com/bc --> | Deprecations? | no <!-- please update UPGRADE-*.md and src/**/CHANGELOG.md files --> | Tests pass? | yes <!-- please add some, will be required by reviewers --> | Fixed tickets | | License | MIT | Doc PR | Refactoring to extend messenger exceptions and extract unrecoverable exception into an interface. The exception is meant for people consuming messages. By using an interface, developers don't need to catch and rethrow or change their exception hierarchies. They can simply implement the interface in their existing exceptions to avoid unnecessary retries. Commits ------- 6a2f4dc Extract unrecoverable exception to interface
2 parents b68a6b3 + 6a2f4dc commit 7f9dad1
Copy full SHA for 7f9dad1
Expand file treeCollapse file tree

8 files changed

+35
-12
lines changed

‎src/Symfony/Component/Messenger/Exception/DelayedMessageHandlingException.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Messenger/Exception/DelayedMessageHandlingException.php
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
*
1818
* @author Tobias Nyholm <tobias.nyholm@gmail.com>
1919
*/
20-
class DelayedMessageHandlingException extends \RuntimeException implements ExceptionInterface
20+
class DelayedMessageHandlingException extends RuntimeException
2121
{
2222
private $exceptions;
2323

‎src/Symfony/Component/Messenger/Exception/MessageDecodingFailedException.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Messenger/Exception/MessageDecodingFailedException.php
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,6 @@
1616
*
1717
* @experimental in 4.3
1818
*/
19-
class MessageDecodingFailedException extends \InvalidArgumentException implements ExceptionInterface
19+
class MessageDecodingFailedException extends InvalidArgumentException
2020
{
2121
}

‎src/Symfony/Component/Messenger/Exception/NoHandlerForMessageException.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Messenger/Exception/NoHandlerForMessageException.php
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,6 @@
1616
*
1717
* @experimental in 4.3
1818
*/
19-
class NoHandlerForMessageException extends \LogicException implements ExceptionInterface
19+
class NoHandlerForMessageException extends LogicException
2020
{
2121
}

‎src/Symfony/Component/Messenger/Exception/UnknownSenderException.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Messenger/Exception/UnknownSenderException.php
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,6 @@
1616
*
1717
* @experimental in 4.3
1818
*/
19-
class UnknownSenderException extends \InvalidArgumentException implements ExceptionInterface
19+
class UnknownSenderException extends InvalidArgumentException
2020
{
2121
}
+26Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
<?php
2+
3+
/*
4+
* This file is part of the Symfony package.
5+
*
6+
* (c) Fabien Potencier <fabien@symfony.com>
7+
*
8+
* For the full copyright and license information, please view the LICENSE
9+
* file that was distributed with this source code.
10+
*/
11+
12+
namespace Symfony\Component\Messenger\Exception;
13+
14+
/**
15+
* Marker interface for exceptions to indicate that handling a message will continue to fail.
16+
*
17+
* If something goes wrong while handling a message that's received from a transport
18+
* and the message should not be retried, a handler can throw such an exception.
19+
*
20+
* @author Tobias Schultze <http://tobion.de>
21+
*
22+
* @experimental in 4.3
23+
*/
24+
interface UnrecoverableExceptionInterface extends \Throwable
25+
{
26+
}

‎src/Symfony/Component/Messenger/Exception/UnrecoverableMessageHandlingException.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Messenger/Exception/UnrecoverableMessageHandlingException.php
+2-5Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,12 @@
1212
namespace Symfony\Component\Messenger\Exception;
1313

1414
/**
15-
* Thrown while handling a message to indicate that handling will continue to fail.
16-
*
17-
* If something goes wrong while handling a message that's received from a transport
18-
* and the message should not be retried, a handler can throw this exception.
15+
* A concrete implementation of UnrecoverableExceptionInterface that can be used directly.
1916
*
2017
* @author Frederic Bouchery <frederic@bouchery.fr>
2118
*
2219
* @experimental in 4.3
2320
*/
24-
class UnrecoverableMessageHandlingException extends RuntimeException
21+
class UnrecoverableMessageHandlingException extends RuntimeException implements UnrecoverableExceptionInterface
2522
{
2623
}

‎src/Symfony/Component/Messenger/Exception/ValidationFailedException.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Messenger/Exception/ValidationFailedException.php
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
*
1919
* @experimental in 4.3
2020
*/
21-
class ValidationFailedException extends \RuntimeException implements ExceptionInterface
21+
class ValidationFailedException extends RuntimeException
2222
{
2323
private $violations;
2424
private $violatingMessage;

‎src/Symfony/Component/Messenger/Worker.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Messenger/Worker.php
+2-2Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
use Symfony\Component\Messenger\Event\WorkerMessageReceivedEvent;
1818
use Symfony\Component\Messenger\Event\WorkerStoppedEvent;
1919
use Symfony\Component\Messenger\Exception\HandlerFailedException;
20-
use Symfony\Component\Messenger\Exception\UnrecoverableMessageHandlingException;
20+
use Symfony\Component\Messenger\Exception\UnrecoverableExceptionInterface;
2121
use Symfony\Component\Messenger\Retry\RetryStrategyInterface;
2222
use Symfony\Component\Messenger\Stamp\DelayStamp;
2323
use Symfony\Component\Messenger\Stamp\ReceivedStamp;
@@ -191,7 +191,7 @@ private function dispatchEvent($event)
191191

192192
private function shouldRetry(\Throwable $e, Envelope $envelope, RetryStrategyInterface $retryStrategy): bool
193193
{
194-
if ($e instanceof UnrecoverableMessageHandlingException) {
194+
if ($e instanceof UnrecoverableExceptionInterface) {
195195
return false;
196196
}
197197

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.