1
0
Fork 0
mirror of synced 2025-04-18 16:41:02 +00:00

add CurlException for credentials catch

This commit is contained in:
Sergey Chazov 2022-02-03 12:36:25 +04:00
parent 658b4c8809
commit 23c59dff76

View file

@ -14,6 +14,7 @@ use Intaro\RetailCrm\Service\CustomerService;
use Intaro\RetailCrm\Vendor\Doctrine\Common\Annotations\AnnotationReader;
use Intaro\RetailCrm\Vendor\Doctrine\Common\Annotations\AnnotationRegistry;
use \Intaro\RetailCrm\Component\Builder\Api\CustomerBuilder;
use RetailCrm\Exception\CurlException;
require_once __DIR__ . '/RetailcrmClasspathBuilder.php';
@ -57,11 +58,14 @@ foreach ($arJsConfig as $ext => $arExt) {
if (empty(ConfigProvider::getSitesAvailable())) {
$client = ClientFactory::createClientAdapter();
$credentials = $client->getCredentials();
try {
ConfigProvider::setSitesAvailable($credentials->sitesAvailable[0] ?? '');
} catch (ArgumentOutOfRangeException $exception) {
$credentials = $client->getCredentials();
ConfigProvider::setSitesAvailable(
count($credentials->sitesAvailable) > 0 ? $credentials->sitesAvailable[0] : ''
);
} catch (ArgumentOutOfRangeException | CurlException $exception) {
Logger::getInstance()->write($exception->getMessage());
}
}