Context manager to wrap encryption related errors.
()
| 124 | |
| 125 | @contextlib.contextmanager |
| 126 | def _wrap_encryption_errors() -> Iterator[None]: |
| 127 | """Context manager to wrap encryption related errors.""" |
| 128 | try: |
| 129 | yield |
| 130 | except BSONError: |
| 131 | # BSON encoding/decoding errors are unrelated to encryption so |
| 132 | # we should propagate them unchanged. |
| 133 | raise |
| 134 | except Exception as exc: |
| 135 | raise EncryptionError(exc) from exc |
| 136 | |
| 137 | |
| 138 | class _EncryptionIO(MongoCryptCallback): # type: ignore[misc] |
no test coverage detected