Skip to content

Commit

Permalink
Handle TooManyRequestsException
Browse files Browse the repository at this point in the history
  • Loading branch information
loevgaard committed Nov 25, 2024
1 parent 21448bf commit 704578b
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
"psr/log": "^1.0 || ^2.0 || ^3.0",
"setono/composite-compiler-pass": "^1.1",
"setono/doctrine-orm-trait": "^1.1",
"setono/peak-wms-php-sdk": "^1.0@alpha",
"setono/peak-wms-php-sdk": "^1.1",
"sylius/admin-bundle": "^1.0",
"sylius/core": "^1.0",
"sylius/core-bundle": "^1.0",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,12 @@
use Setono\Doctrine\ORMTrait;
use Setono\PeakWMS\Client\ClientInterface;
use Setono\PeakWMS\DataTransferObject\Product\Product;
use Setono\PeakWMS\Exception\TooManyRequestsException;
use Setono\SyliusPeakPlugin\DataMapper\Product\ProductDataMapperInterface;
use Setono\SyliusPeakPlugin\Message\Command\ProcessUploadProductVariantRequest;
use Setono\SyliusPeakPlugin\Model\UploadProductVariantRequestInterface;
use Setono\SyliusPeakPlugin\Workflow\UploadProductVariantRequestWorkflow;
use Symfony\Component\Messenger\Exception\RecoverableMessageHandlingException;
use Symfony\Component\Messenger\Exception\UnrecoverableMessageHandlingException;
use Symfony\Component\Workflow\WorkflowInterface;

Expand Down Expand Up @@ -63,6 +65,13 @@ public function __invoke(ProcessUploadProductVariantRequest $message): void
}

$this->uploadProductVariantRequestWorkflow->apply($uploadProductVariantRequest, UploadProductVariantRequestWorkflow::TRANSITION_UPLOAD);
} catch (TooManyRequestsException $e) {
$this->uploadProductVariantRequestWorkflow->apply($uploadProductVariantRequest, UploadProductVariantRequestWorkflow::TRANSITION_RESET);

throw new RecoverableMessageHandlingException(
message: sprintf('Failed to process upload product variant request with id %d', $message->uploadProductVariantRequest),
previous: $e,
);
} catch (\Throwable $e) {
$uploadProductVariantRequest->setError($e->getMessage());

Expand Down

0 comments on commit 704578b

Please sign in to comment.