MCPcopy Index your code
hub / github.com/mongodb/mongo-python-driver / _raise_bulk_write_error

Function _raise_bulk_write_error

pymongo/bulk_shared.py:116–131  ·  view source on GitHub ↗

Raise a BulkWriteError from the full bulk api result.

(full_result: _DocumentOut)

Source from the content-addressed store, hash-verified

114
115
116def _raise_bulk_write_error(full_result: _DocumentOut) -> NoReturn:
117 """Raise a BulkWriteError from the full bulk api result."""
118 # retryWrites on MMAPv1 should raise an actionable error.
119 if full_result["writeErrors"]:
120 full_result["writeErrors"].sort(key=lambda error: error["index"])
121 err = full_result["writeErrors"][0]
122 code = err["code"]
123 msg = err["errmsg"]
124 if code == 20 and msg.startswith("Transaction numbers"):
125 errmsg = (
126 "This MongoDB deployment does not support "
127 "retryable writes. Please add retryWrites=false "
128 "to your connection string."
129 )
130 raise OperationFailure(errmsg, code, full_result)
131 raise BulkWriteError(full_result)

Callers 4

_execute_commandMethod · 0.90
execute_commandMethod · 0.90
_execute_commandMethod · 0.90
execute_commandMethod · 0.90

Calls 3

OperationFailureClass · 0.90
BulkWriteErrorClass · 0.90
sortMethod · 0.45

Tested by

no test coverage detected