vortex_error/
python.rs

1// SPDX-License-Identifier: Apache-2.0
2// SPDX-FileCopyrightText: Copyright the Vortex contributors
3
4//! Python bindings for Vortex errors.
5
6use std::backtrace::Backtrace;
7
8use pyo3::PyErr;
9#[cfg(feature = "python")]
10use pyo3::exceptions::PyValueError;
11
12use crate::VortexError;
13
14impl From<VortexError> for PyErr {
15    fn from(value: VortexError) -> Self {
16        PyValueError::new_err(value.to_string())
17    }
18}
19
20impl From<PyErr> for VortexError {
21    fn from(value: PyErr) -> Self {
22        VortexError::InvalidArgument(value.to_string().into(), Box::new(Backtrace::capture()))
23    }
24}