comparison rust/hg-cpython/src/exceptions.rs @ 48519:35ebe6f824be

hg-cpython: use ancestor iterator impls from vcsgraph Differential Revision: https://phab.mercurial-scm.org/D11947
author pacien <pacien.trangirard@pacien.net>
date Tue, 16 Nov 2021 18:54:05 +0100
parents f96b28aa4b79
children 3aca98a35727
comparison
equal deleted inserted replaced
48518:8e8737a1fa7d 48519:35ebe6f824be
35 Ok(cls) => PyErr::from_instance(py, cls), 35 Ok(cls) => PyErr::from_instance(py, cls),
36 } 36 }
37 } 37 }
38 } 38 }
39 } 39 }
40
41 pub fn pynew_from_vcsgraph(
42 py: Python,
43 inner: vcsgraph::graph::GraphReadError,
44 ) -> PyErr {
45 match inner {
46 vcsgraph::graph::GraphReadError::InconsistentGraphData => {
47 GraphError::new(py, "InconsistentGraphData")
48 }
49 vcsgraph::graph::GraphReadError::InvalidKey => {
50 GraphError::new(py, "ParentOutOfRange")
51 }
52 vcsgraph::graph::GraphReadError::KeyedInvalidKey(r) => {
53 GraphError::new(py, ("ParentOutOfRange", r))
54 }
55 vcsgraph::graph::GraphReadError::WorkingDirectoryUnsupported => {
56 match py
57 .import("mercurial.error")
58 .and_then(|m| m.get(py, "WdirUnsupported"))
59 {
60 Err(e) => e,
61 Ok(cls) => PyErr::from_instance(py, cls),
62 }
63 }
64 }
65 }
40 } 66 }
41 67
42 py_exception!(rustext, HgPathPyError, RuntimeError); 68 py_exception!(rustext, HgPathPyError, RuntimeError);
43 py_exception!(rustext, FallbackError, RuntimeError); 69 py_exception!(rustext, FallbackError, RuntimeError);
44 py_exception!(shared_ref, AlreadyBorrowed, RuntimeError); 70 py_exception!(shared_ref, AlreadyBorrowed, RuntimeError);