Skip to content

Commit

Permalink
Add TooManyRequestsException
Browse files Browse the repository at this point in the history
  • Loading branch information
loevgaard committed Nov 25, 2024
1 parent c5e6105 commit 23dcfd2
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/Client/Client.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
use Setono\PeakWMS\Exception\InternalServerErrorException;
use Setono\PeakWMS\Exception\NotAuthorizedException;
use Setono\PeakWMS\Exception\NotFoundException;
use Setono\PeakWMS\Exception\TooManyRequestsException;
use Setono\PeakWMS\Exception\UnexpectedStatusCodeException;
use Setono\PeakWMS\Request\Query\Query;

Expand Down Expand Up @@ -269,6 +270,7 @@ private static function assertStatusCode(ResponseInterface $response): void

NotAuthorizedException::assert($response);
NotFoundException::assert($response);
TooManyRequestsException::assert($response);
InternalServerErrorException::assert($response);

throw new UnexpectedStatusCodeException($response);
Expand Down
17 changes: 17 additions & 0 deletions src/Exception/TooManyRequestsException.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?php

declare(strict_types=1);

namespace Setono\PeakWMS\Exception;

use Psr\Http\Message\ResponseInterface;

final class TooManyRequestsException extends ResponseAwareException
{
public static function assert(ResponseInterface $response): void
{
if ($response->getStatusCode() === 429) {
throw new self($response);
}
}
}

0 comments on commit 23dcfd2

Please sign in to comment.