Skip to content

feat: Introduce OxbowError with backtrace capture via thiserror#166

Merged
nvictus merged 1 commit intoabdenlab:mainfrom
nvictus:feat-crate-errors
Mar 6, 2026
Merged

feat: Introduce OxbowError with backtrace capture via thiserror#166
nvictus merged 1 commit intoabdenlab:mainfrom
nvictus:feat-crate-errors

Conversation

@nvictus
Copy link
Copy Markdown
Member

@nvictus nvictus commented Mar 6, 2026

This PR replaces io::Error throughout the oxbow crate with a custom OxbowError enum using thiserror 2.x. This enum captures backtraces at error creation time, making errors from Rust traceable when they surface in Python. Previously, only a bare string message was shown.

Six variants map to the semantic categories already in use: InvalidInput, InvalidData, NotFound, Io, Arrow, External.

When RUST_BACKTRACE=1 is set, the backtrace is baked into the ArrowError string at the RecordBatchReader boundary so that it survives the CFFI. On the py-oxbow side, OxbowError variants map to appropriate exception types (PyValueError, PyKeyError, PyIOError) via a to_py() converter.

Note

Backtraces are captured via std::backtrace::Backtrace (stable since Rust 1.65) inside a CapturedBacktrace newtype that avoids triggering code generation by thiserror using the currently unstable Error::provide(). We will revisit once provide() is stabilized in Rust.

Replace io::Error throughout the oxbow crate with a custom OxbowError
enum (thiserror 2.x) that captures backtraces at error creation time.
This makes parsing and validation errors from Rust actionable when they
surface in Python, where previously only a bare string message was shown.

Six variants map to the semantic categories already in use:
InvalidInput, InvalidData, NotFound, Io, Arrow, External.

Backtraces are captured via std::backtrace::Backtrace (stable since
Rust 1.65) inside a CapturedBacktrace newtype that avoids triggering
thiserror's unstable Error::provide() codegen. When RUST_BACKTRACE=1
is set, the backtrace is baked into the ArrowError string at the
RecordBatchReader boundary so it survives the Arrow C Stream Interface.

On the Python side, OxbowError variants map to appropriate exception
types (PyValueError, PyKeyError, PyIOError) via a to_py() converter.
@nvictus nvictus requested a review from conradbzura March 6, 2026 21:43
@nvictus nvictus merged commit 99526b0 into abdenlab:main Mar 6, 2026
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant