Mercurial > public > mercurial-scm > hg-stable
changeset 52439:20c0472b2ab7
rust-pyo3: defining GraphError
This pretty much parallels the way in works with `cpython`. A warning, though:
this new `pyo3_rustext.GraphError` is not the same as `rustext.GraphError`, yet
both subclass `ValueError`.
author | Georges Racinet <georges.racinet@cloudcrane.io> |
---|---|
date | Sat, 30 Nov 2024 20:27:11 +0100 |
parents | c5128c541021 |
children | a642c0a3860f |
files | rust/hg-pyo3/src/exceptions.rs rust/hg-pyo3/src/lib.rs |
diffstat | 2 files changed, 6 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/rust/hg-pyo3/src/exceptions.rs Sat Nov 30 20:27:11 2024 +0100 @@ -0,0 +1,4 @@ +use pyo3::create_exception; +use pyo3::exceptions::PyValueError; + +create_exception!(pyo3_rustext, GraphError, PyValueError);
--- a/rust/hg-pyo3/src/lib.rs Fri Nov 29 23:47:37 2024 +0100 +++ b/rust/hg-pyo3/src/lib.rs Sat Nov 30 20:27:11 2024 +0100 @@ -1,6 +1,7 @@ use pyo3::prelude::*; mod dagops; +mod exceptions; mod util; #[pymodule] @@ -15,5 +16,6 @@ let dotted_name = format!("mercurial.{}", name); m.add_submodule(&dagops::init_module(py, &dotted_name)?)?; + m.add("GraphError", py.get_type::<exceptions::GraphError>())?; Ok(()) }