diff --git a/src/Api/HttpApi.php b/src/Api/HttpApi.php index a347c01..d7c28c3 100644 --- a/src/Api/HttpApi.php +++ b/src/Api/HttpApi.php @@ -99,6 +99,8 @@ abstract class HttpApi throw HttpClientException::conflict($response); case 413: throw HttpClientException::payloadTooLarge($response); + case 429: + throw HttpClientException::tooManyRequests($response); case 500 <= $statusCode: throw HttpServerException::serverError($statusCode); default: diff --git a/src/Exception/HttpClientException.php b/src/Exception/HttpClientException.php index 8067e44..f073f7b 100644 --- a/src/Exception/HttpClientException.php +++ b/src/Exception/HttpClientException.php @@ -88,6 +88,11 @@ final class HttpClientException extends \RuntimeException implements Exception return new self('Payload too large, your total attachment size is too big.', 413, $response); } + public static function tooManyRequests(ResponseInterface $response) + { + return new self('Too many requests.', 429, $response); + } + public static function forbidden(ResponseInterface $response) { $body = $response->getBody()->__toString();