Replies: 1 comment 1 reply
-
|
Well, I think I found a workaround. There's this section in the documentation about "creating more complex exceptions", but it is incomplete. It's missing instructions on how to instantiate and return these, because they don't have the Here's how I did it in my code: #[pyclass(name = "Problem", extends=PyException, frozen)]
pub struct PyProblem {
/// Inner problem.
pub inner: Problem,
}
impl PyProblem {
/// Constructor.
pub fn new_err(inner: Problem) -> PyResult<PyErr> {
Python::attach(|py| {
let problem = Bound::new(py, Self { inner })?;
Ok(PyErr::from_value(problem.into_any()))
})
}
}This seems to work. However, I'm still unclear as to why |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
The types do not implement
PyClass, so it's impossible to use#[pymethods]with them.Beta Was this translation helpful? Give feedback.
All reactions