protected static function throwTransportableExceptionIfNeeded(
        array $response,
        string $url = ''
    ) {
        if (
            !isset($response['code']) ||
            0 === $response['code']
        ) {
            throw ConnectionException::buildConnectExceptionByUrl($url);
        }

        switch ($response['code']) {
            case ResourceNotAvailableException::getTransportableHTTPError():
                throw new ResourceNotAvailableException($response['body']['message']);
            case InvalidTokenException::getTransportableHTTPError():
                throw new InvalidTokenException($response['body']['message']);
            case InvalidFormatException::getTransportableHTTPError():
                throw new InvalidFormatException($response['body']['message']);
            case ResourceExistsException::getTransportableHTTPError():
                throw new ResourceExistsException($response['body']['message']);
            case ForbiddenException::getTransportableHTTPError():
                throw new ForbiddenException($response['body']['message']);
            case ConnectionException::getTransportableHTTPError():
                throw new ConnectionException('Apisearch returned an internal error code [500]');
        }
    }