DOES::wrapOpCall

  1. Bitrix24 API (v. 23.675.0)
  2. tasks
  3. DOES
  4. wrapOpCall
  • Модуль: tasks
  • Путь к файлу: ~/bitrix/modules/tasks/lib/dispatcher.php
  • Класс: BitrixTasksDOES
  • Вызов: DOES::wrapOpCall
private function wrapOpCall($operation)
{
	$callResult = array();
	try
	{
		$callResult = $operation->call();
	}
	catch(TasksException $e) // old-style tasks exception
	{
		$errorCode = static::getErrorCodeByTasksException($e);

		if($errorCode !== false)
		{
			$reasonsAdded = false;
			if($e->checkOfType(TasksException::TE_FLAG_SERIALIZED_ERRORS_IN_MESSAGE) && $e->getMessage() !== false)
			{
				$errors = BitrixTasksUtilType::unSerializeArray($e->getMessage());
				foreach ($errors as $error)
				{
					$operation->getErrors()->add((string) $error["id"] == '' ? 'ACTION_FAILED_REASON' : $error["id"], htmlspecialcharsBack($error["text"]));
					$reasonsAdded = true;
				}
			}

			if(!$reasonsAdded)
			{
				$operation->getErrors()->add($errorCode, static::proxyExceptionMessage($e));
			}
		}
		else
		{
			throw $e; // let it log
		}
	}
	catch(BitrixTasksAccessDeniedException $e)
	{
		// access to the entity is not allowed
		$operation->getErrors()->add('ACCESS_DENIED', static::proxyExceptionMessage($e));
	}
	catch(BitrixTasksActionNotAllowedException $e)
	{
		// access to the entity is generally allowed, but the certain action is forbidden to execute
		$operation->getErrors()->add('ACTION_NOT_ALLOWED', static::proxyExceptionMessage($e));
		static::addReasons($operation, $e->getErrors(), 'ACTION_NOT_ALLOWED');
	}
	catch(BitrixTasksActionFailedException $e)
	{
		// action was allowed, but due to some reasons execution failed
		$operation->getErrors()->add('ACTION_FAILED', static::proxyExceptionMessage($e));
		$errors = $e->getErrors();

		if(is_array($errors) && !empty($errors))
		{
			foreach($errors as $error)
			{
				$operation->getErrors()->add('ACTION_FAILED_REASON', $error);
			}
		}
	}
	catch(BitrixTasksException $e)
	{
		// some general tasks error, no idea what to do
		$operation->getErrors()->add('ACTION_FAILED', static::proxyExceptionMessage($e));
		$errors = $e->getErrors();

		if(is_array($errors) && !empty($errors))
		{
			foreach($errors as $error)
			{
				$operation->getErrors()->add('ACTION_FAILED_REASON', $error);
			}
		}
	}

	return $callResult;
}

Добавить комментарий