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