Raise a BulkWriteError from the full bulk api result.
(full_result: _DocumentOut)
| 114 | |
| 115 | |
| 116 | def _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) |
no test coverage detected