Skip to content

Commit

Permalink
update batch error description
Browse files Browse the repository at this point in the history
  • Loading branch information
simorenoh committed Feb 27, 2024
1 parent fa4b95f commit 9fbe949
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
9 changes: 8 additions & 1 deletion sdk/cosmos/azure-cosmos/azure/cosmos/aio/_container.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]]
Expand All @@ -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:
Expand Down
9 changes: 8 additions & 1 deletion sdk/cosmos/azure-cosmos/azure/cosmos/container.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]]
Expand All @@ -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:
Expand Down

0 comments on commit 9fbe949

Please sign in to comment.