@@ -1752,6 +1752,7 @@ def insert_many(
17521752 merge : Optional [bool ] = None ,
17531753 refill_index_caches : Optional [bool ] = None ,
17541754 version_attribute : Optional [str ] = None ,
1755+ raise_on_document_error : bool = False ,
17551756 ) -> Result [Union [bool , List [Union [Json , ArangoServerError ]]]]:
17561757 """Insert multiple documents.
17571758
@@ -1761,7 +1762,8 @@ def insert_many(
17611762 returned as an object in the result list. It is up to you to
17621763 inspect the list to determine which documents were inserted
17631764 successfully (returns document metadata) and which were not
1764- (returns exception object).
1765+ (returns exception object). Alternatively, you can rely on
1766+ setting **raise_on_document_error** to True (defaults to False).
17651767
17661768 :param documents: List of new documents to insert. If they contain the
17671769 "_key" or "_id" fields, the values are used as the keys of the new
@@ -1801,6 +1803,11 @@ def insert_many(
18011803 :param version_attribute: support for simple external versioning to
18021804 document operations.
18031805 :type version_attribute: str
1806+ :param raise_on_document_error: Whether to raise if a DocumentRevisionError
1807+ or a DocumentInsertError is encountered on an individual document,
1808+ as opposed to returning the error as an object in the result list.
1809+ Defaults to False.
1810+ :type raise_on_document_error: bool
18041811 :return: List of document metadata (e.g. document keys, revisions) and
18051812 any exception, or True if parameter **silent** was set to True.
18061813 :rtype: [dict | ArangoServerError] | bool
@@ -1853,7 +1860,12 @@ def response_handler(
18531860 results .append (body )
18541861 else :
18551862 sub_resp = self ._conn .prep_bulk_err_response (resp , body )
1856- results .append (DocumentInsertError (sub_resp , request ))
1863+ error = DocumentInsertError (sub_resp , request )
1864+
1865+ if raise_on_document_error :
1866+ raise error
1867+
1868+ results .append (error )
18571869
18581870 return results
18591871
@@ -2228,6 +2240,7 @@ def delete_many(
22282240 sync : Optional [bool ] = None ,
22292241 silent : bool = False ,
22302242 refill_index_caches : Optional [bool ] = None ,
2243+ raise_on_document_error : bool = False ,
22312244 ) -> Result [Union [bool , List [Union [Json , ArangoServerError ]]]]:
22322245 """Delete multiple documents.
22332246
@@ -2256,6 +2269,11 @@ def delete_many(
22562269 index caches if document operations affect the edge index or
22572270 cache-enabled persistent indexes.
22582271 :type refill_index_caches: bool | None
2272+ :param raise_on_document_error: Whether to raise if a DocumentRevisionError
2273+ or a DocumentDeleteError is encountered on an individual document,
2274+ as opposed to returning the error as an object in the result list.
2275+ Defaults to False.
2276+ :type raise_on_document_error: bool
22592277 :return: List of document metadata (e.g. document keys, revisions) and
22602278 any exceptions, or True if parameter **silent** was set to True.
22612279 :rtype: [dict | ArangoServerError] | bool
@@ -2307,6 +2325,10 @@ def response_handler(
23072325 error = DocumentRevisionError (sub_resp , request )
23082326 else :
23092327 error = DocumentDeleteError (sub_resp , request )
2328+
2329+ if raise_on_document_error :
2330+ raise error
2331+
23102332 results .append (error )
23112333
23122334 return results
0 commit comments