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

Class BulkWriteError

pymongo/errors.py:284–309  ·  view source on GitHub ↗

Exception class for bulk write errors. .. versionadded:: 2.7

Source from the content-addressed store, hash-verified

282
283
284class BulkWriteError(OperationFailure):
285 """Exception class for bulk write errors.
286
287 .. versionadded:: 2.7
288 """
289
290 details: _DocumentOut
291
292 def __init__(self, results: _DocumentOut) -> None:
293 super().__init__("batch op errors occurred", 65, results)
294
295 def __reduce__(self) -> tuple[Any, Any]:
296 return self.__class__, (self.details,)
297
298 @property
299 def timeout(self) -> bool:
300 # Check the last writeConcernError and last writeError to determine if this
301 # BulkWriteError was caused by a timeout.
302 wces = self.details.get("writeConcernErrors", [])
303 if wces and _wtimeout_error(wces[-1]):
304 return True
305
306 werrs = self.details.get("writeErrors", [])
307 if werrs and werrs[-1].get("code") == 50:
308 return True
309 return False
310
311
312class ClientBulkWriteException(OperationFailure):

Callers 2

_raise_bulk_write_errorFunction · 0.90

Calls

no outgoing calls

Tested by 1