From 9fbe94922d8428278366d3031eea2661da136bf3 Mon Sep 17 00:00:00 2001 From: simorenoh Date: Tue, 27 Feb 2024 11:40:18 -0800 Subject: [PATCH] update batch error description --- sdk/cosmos/azure-cosmos/azure/cosmos/aio/_container.py | 9 ++++++++- sdk/cosmos/azure-cosmos/azure/cosmos/container.py | 9 ++++++++- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/sdk/cosmos/azure-cosmos/azure/cosmos/aio/_container.py b/sdk/cosmos/azure-cosmos/azure/cosmos/aio/_container.py index cf7197ef1f32..c749defdd0c7 100644 --- a/sdk/cosmos/azure-cosmos/azure/cosmos/aio/_container.py +++ b/sdk/cosmos/azure-cosmos/azure/cosmos/aio/_container.py @@ -1028,7 +1028,8 @@ async def execute_item_batch( priority: Optional[Literal["High", "Low"]] = None, **kwargs: Any ) -> List[Dict[str, Any]]: - """ Executes the transactional batch for the specified partition key. + """ Executes the transactional batch for the specified partition key. Transactional batches either succeed or + fail in their entirety. :param batch_operations: The batch of operations to be executed. :type batch_operations: List[Tuple[Any]] @@ -1047,6 +1048,12 @@ async def execute_item_batch( :returns: A list representing the items after the batch operations went through. :raises ~azure.cosmos.exceptions.CosmosHttpResponseError: The batch failed to execute. :raises ~azure.cosmos.exceptions.CosmosBatchOperationError: A transactional batch operation failed in the batch. + CosmosBatchOperationError will have several attributes providing the user more information on the error: + - error_index: the index of the failed operation + - headers: the response headers for the failed operation + - status_code: the status code of the failed operation, since all other operations will fail with a 424 + - message: the error message, also including the index of the failed operation + - operation_responses: the list of failed operation responses :rtype: List[Dict[str, Any]] """ if pre_trigger_include is not None: diff --git a/sdk/cosmos/azure-cosmos/azure/cosmos/container.py b/sdk/cosmos/azure-cosmos/azure/cosmos/container.py index 35dedd32e164..1ceaf576513c 100644 --- a/sdk/cosmos/azure-cosmos/azure/cosmos/container.py +++ b/sdk/cosmos/azure-cosmos/azure/cosmos/container.py @@ -778,7 +778,8 @@ def execute_item_batch( priority: Optional[Literal["High", "Low"]] = None, **kwargs: Any ) -> List[Dict[str, Any]]: - """ Executes the transactional batch for the specified partition key. + """ Executes the transactional batch for the specified partition key. Transactional batches either succeed or + fail in their entirety. :param batch_operations: The batch of operations to be executed. :type batch_operations: List[Tuple[Any]] @@ -797,6 +798,12 @@ def execute_item_batch( :returns: A list representing the item after the batch operations went through. :raises ~azure.cosmos.exceptions.CosmosHttpResponseError: The batch failed to execute. :raises ~azure.cosmos.exceptions.CosmosBatchOperationError: A transactional batch operation failed in the batch. + CosmosBatchOperationError will have several attributes providing the user more information on the error: + - error_index: the index of the failed operation + - headers: the response headers for the failed operation + - status_code: the status code of the failed operation, since all other operations will fail with a 424 + - message: the error message, also including the index of the failed operation + - operation_responses: the list of failed operation responses :rtype: List[Dict[str, Any]] """ if pre_trigger_include is not None: