Skip to content

Commit

Permalink
Merge pull request #517 from makeroi/patch-11
Browse files Browse the repository at this point in the history
Реализовано отдельное исключение для 429
  • Loading branch information
bessudnov authored Sep 4, 2023
2 parents 8c70d65 + d497523 commit 97fe9d9
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/AmoCRM/Client/AmoCRMApiRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -594,6 +594,9 @@ private function parseResponse(ResponseInterface $response): array
&& !$decodedBody
&& !empty($bodyContents)
) {
if($e->getCode() == 429) {
throw new AmoCRMApiTooManyRequestsException("Too many requests", $e->getCode(), $this->getLastRequestInfo());
}
throw new AmoCRMApiException(
"Response body is not json",
$response->getStatusCode(),
Expand Down
14 changes: 14 additions & 0 deletions src/AmoCRM/Exceptions/AmoCRMApiTooManyRequestsException.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?php

namespace AmoCRM\Exceptions;

/**
* Class AmoCRMApiHttpClientException
*
* Выбрасывается в случае ответа от сервера с кодом 429
*
* @package AmoCRM\Exceptions
*/
class AmoCRMApiTooManyRequestsException extends AmoCRMApiHttpClientException
{
}

0 comments on commit 97fe9d9

Please sign in to comment.