##// END OF EJS Templates
rust-pyo3: conversions to GraphError Python exception...
Georges Racinet -
r53309:6e8ba528 default
parent child Browse files
Show More
@@ -722,6 +722,7 dependencies = [
722 "pyo3",
722 "pyo3",
723 "python3-sys",
723 "python3-sys",
724 "stable_deref_trait",
724 "stable_deref_trait",
725 "vcsgraph",
725 ]
726 ]
726
727
727 [[package]]
728 [[package]]
@@ -18,4 +18,5 log = "0.4.17"
18 derive_more = "0.99.17"
18 derive_more = "0.99.17"
19 env_logger = "0.9.3"
19 env_logger = "0.9.3"
20 lazy_static = "*"
20 lazy_static = "*"
21 vcsgraph = "0.2.0"
21
22
@@ -1,4 +1,34
1 use pyo3::create_exception;
2 use pyo3::exceptions::PyValueError;
1 use pyo3::exceptions::PyValueError;
2 use pyo3::import_exception;
3 use pyo3::{create_exception, PyErr};
4
5 use crate::revision::PyRevision;
3
6
4 create_exception!(pyo3_rustext, GraphError, PyValueError);
7 create_exception!(pyo3_rustext, GraphError, PyValueError);
8 import_exception!(mercurial.error, WdirUnsupported);
9
10 impl GraphError {
11 pub fn from_hg(inner: hg::GraphError) -> PyErr {
12 match inner {
13 hg::GraphError::ParentOutOfRange(r) => {
14 GraphError::new_err(("ParentOutOfRange", PyRevision(r.0)))
15 }
16 }
17 }
18 pub fn from_vcsgraph(inner: vcsgraph::graph::GraphReadError) -> PyErr {
19 match inner {
20 vcsgraph::graph::GraphReadError::InconsistentGraphData => {
21 GraphError::new_err("InconsistentGraphData")
22 }
23 vcsgraph::graph::GraphReadError::InvalidKey => {
24 GraphError::new_err("ParentOutOfRange")
25 }
26 vcsgraph::graph::GraphReadError::KeyedInvalidKey(r) => {
27 GraphError::new_err(("ParentOutOfRange", r))
28 }
29 vcsgraph::graph::GraphReadError::WorkingDirectoryUnsupported => {
30 WdirUnsupported::new_err(())
31 }
32 }
33 }
34 }
General Comments 0
You need to be logged in to leave comments. Login now