diff --git a/src/Core/ApiLevelErrorHandler.php b/src/Core/ApiLevelErrorHandler.php index b25deae..dd2232b 100644 --- a/src/Core/ApiLevelErrorHandler.php +++ b/src/Core/ApiLevelErrorHandler.php @@ -8,14 +8,12 @@ use Bitrix24\SDK\Core\Exceptions\MethodNotFoundException; use Bitrix24\SDK\Core\Exceptions\OperationTimeLimitExceededException; use Bitrix24\SDK\Core\Exceptions\QueryLimitExceededException; +use Bitrix24\SDK\Services\Workflows\Exceptions\ActivityOrRobotAlreadyInstalledException; +use Bitrix24\SDK\Services\Workflows\Exceptions\ActivityOrRobotValidationFailureException; use Psr\Log\LoggerInterface; /** * Handle api-level errors and throw related exception - * - * Class ApiLevelErrorHandler - * - * @package Bitrix24\SDK\Core */ class ApiLevelErrorHandler { @@ -90,6 +88,10 @@ private function handleError(array $responseBody, ?string $batchCommandId = null throw new MethodNotFoundException(sprintf('api method not found %s %s', $errorDescription, $batchErrorPrefix)); case 'operation_time_limit': throw new OperationTimeLimitExceededException(sprintf('operation time limit exceeded %s %s', $errorDescription, $batchErrorPrefix)); + case 'error_activity_already_installed': + throw new ActivityOrRobotAlreadyInstalledException(sprintf('%s - %s', $errorCode, $errorDescription)); + case 'error_activity_validation_failure': + throw new ActivityOrRobotValidationFailureException(sprintf('%s - %s', $errorCode, $errorDescription)); default: throw new BaseException(sprintf('%s - %s %s', $errorCode, $errorDescription, $batchErrorPrefix)); } diff --git a/src/Core/Core.php b/src/Core/Core.php index 7351139..979aa78 100644 --- a/src/Core/Core.php +++ b/src/Core/Core.php @@ -108,6 +108,16 @@ public function call(string $apiMethod, array $parameters = []): Response // dispatch event, application listeners update domain url host in accounts repository $this->eventDispatcher->dispatch(new PortalDomainUrlChangedEvent($portalOldDomainUrlHost, $portalNewDomainUrlHost)); break; + case StatusCodeInterface::STATUS_BAD_REQUEST: + $body = $apiCallResponse->toArray(false); + $this->logger->notice( + 'bad request', + [ + 'body' => $body, + ] + ); + $this->apiLevelErrorHandler->handle($body); + break; case StatusCodeInterface::STATUS_UNAUTHORIZED: $body = $apiCallResponse->toArray(false); $this->logger->debug( diff --git a/src/Services/Workflows/Exceptions/ActivityOrRobotAlreadyInstalledException.php b/src/Services/Workflows/Exceptions/ActivityOrRobotAlreadyInstalledException.php new file mode 100644 index 0000000..bb3ee0e --- /dev/null +++ b/src/Services/Workflows/Exceptions/ActivityOrRobotAlreadyInstalledException.php @@ -0,0 +1,9 @@ +