Skip to content
This repository was archived by the owner on Jun 25, 2025. It is now read-only.

Transform exception when received the error #123

Merged
merged 1 commit into from
Sep 7, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions Http/HttpResponsesToException.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
use Apisearch\Exception\InvalidTokenException;
use Apisearch\Exception\ResourceExistsException;
use Apisearch\Exception\ResourceNotAvailableException;
use Apisearch\Exception\TooManyRequestsException;

/**
* Class HttpResponsesToException.
Expand Down Expand Up @@ -57,6 +58,8 @@ protected static function throwTransportableExceptionIfNeeded(
throw new ResourceExistsException($response['body']['message']);
case ForbiddenException::getTransportableHTTPError():
throw new ForbiddenException($response['body']['message']);
case TooManyRequestsException::getTransportableHTTPError();
throw new TooManyRequestsException($response['body']['message']);
case ConnectionException::getTransportableHTTPError():
throw new ConnectionException('Apisearch returned an internal error code [500] - ' . $response['body']['message']);
}
Expand Down