Convert error to a NetworkTimeout or ExecutionTimeout as appropriate.
(error: BaseException)
| 513 | |
| 514 | |
| 515 | def _make_timeout_error(error: BaseException) -> PyMongoError: |
| 516 | """Convert error to a NetworkTimeout or ExecutionTimeout as appropriate.""" |
| 517 | if _csot.remaining() is not None: |
| 518 | timeout_error: PyMongoError = ExecutionTimeout( |
| 519 | str(error), 50, {"ok": 0, "errmsg": str(error), "code": 50} |
| 520 | ) |
| 521 | else: |
| 522 | timeout_error = NetworkTimeout(str(error)) |
| 523 | if isinstance(error, PyMongoError): |
| 524 | timeout_error._error_labels = error._error_labels.copy() |
| 525 | return timeout_error |
| 526 | |
| 527 | |
| 528 | _T = TypeVar("_T") |
no test coverage detected