Support for HTTP 429 Too Many Requests code

This commit is contained in:
Artem Bondarenko 2021-05-13 21:01:15 +03:00 committed by David Garcia
parent f109b4a2f7
commit a0352e8f51
2 changed files with 7 additions and 0 deletions

View File

@ -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:

View File

@ -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();