|
16 | 16 | raw to connector callers. Wrapped in |
17 | 17 | ``OperationalError`` here. |
18 | 18 |
|
19 | | -Local missing transfer files use the built-in ``FileNotFoundError`` class; |
20 | | -the original OS error code and requested local filename are preserved |
21 | | -when available. |
| 19 | +Local transfer failures use built-in ``OSError`` classes, including |
| 20 | +``FileNotFoundError``, ``PermissionError`` and other platform subclasses. |
| 21 | +The original OS error code and requested filename are preserved when available. |
22 | 22 |
|
23 | 23 | These primitives live in their own module so both ``client.py`` |
24 | 24 | (which orchestrates PyO3 calls) and ``result_set.py`` (which calls |
@@ -126,8 +126,9 @@ def reraise_kernel_error( |
126 | 126 | ) -> "Union[Error, OSError]": |
127 | 127 | """Map a kernel error and forward its structured attributes. |
128 | 128 |
|
129 | | - Local missing files use ``FileNotFoundError``; filesystem permission |
130 | | - failures use ``PermissionError``. Other errors use PEP 249 classes. |
| 129 | + Local transfer failures use built-in ``OSError`` classes, including |
| 130 | + missing-file, permission, directory and disk-full errors. Non-local |
| 131 | + errors use PEP 249 classes. |
131 | 132 |
|
132 | 133 | The returned exception is raised by callers with ``raise ... from |
133 | 134 | exc``; the ``from`` clause is what sets ``__cause__``, so we don't |
@@ -169,7 +170,11 @@ def reraise_kernel_error( |
169 | 170 | os_error_filename = getattr(exc, "os_error_filename", None) |
170 | 171 | file_error_args: tuple |
171 | 172 | if os_error_code is None: |
172 | | - file_error_args = (message,) |
| 173 | + file_error_args = ( |
| 174 | + (None, message, os_error_filename) |
| 175 | + if os_error_filename is not None |
| 176 | + else (message,) |
| 177 | + ) |
173 | 178 | elif os.name == "nt": |
174 | 179 | file_error_args = (0, message, os_error_filename, os_error_code) |
175 | 180 | else: |
@@ -221,8 +226,8 @@ def wrap_kernel_exception(what: str, exc: BaseException) -> "Union[Error, OSErro |
221 | 226 | """Map a PyO3 exception to the connector's public error contract. |
222 | 227 |
|
223 | 228 | - ``KernelError`` → mapped class with structured attrs forwarded. |
224 | | - A local missing transfer file maps to ``FileNotFoundError`` with |
225 | | - its original OS error code and requested filename when available. |
| 229 | + Local transfer failures map to built-in ``OSError`` classes with |
| 230 | + their original OS error code and requested filename when available. |
226 | 231 | - Already-mapped PEP 249 or local transfer errors → passed through |
227 | 232 | unchanged so nested callers preserve their class and attributes. |
228 | 233 | - Anything else (``TypeError`` / ``ValueError`` / etc. from PyO3 |
|
0 commit comments