Skip to main content

gen_pyo3_error_methods_impl

Function gen_pyo3_error_methods_impl 

Source
pub fn gen_pyo3_error_methods_impl(error: &ErrorDef) -> String
Expand description

Generate a #[pyclass] companion struct for error introspection, exposing the whitelisted methods as #[getter] properties.

pyo3::create_exception! types are zero-sized marker types that do not implement PyClass, so #[pymethods] blocks cannot be added to them directly. Instead we emit a separate {ErrorName}Info #[pyclass] that stores the three fields and is built by a #[pyfunction] free function which extracts the values from the exception’s args tuple (indices 1–3, which the converter already populates).

Returns an empty string when error.methods is empty.