Show More
@@ -33,4 +33,5 b' pub trait Graph {' | |||||
33 | #[derive(Clone, Debug, PartialEq)] |
|
33 | #[derive(Clone, Debug, PartialEq)] | |
34 | pub enum GraphError { |
|
34 | pub enum GraphError { | |
35 | ParentOutOfRange(Revision), |
|
35 | ParentOutOfRange(Revision), | |
|
36 | WorkingDirectoryUnsupported, | |||
36 | } |
|
37 | } |
@@ -8,6 +8,8 b'' | |||||
8 | //! Bindings for Rust errors |
|
8 | //! Bindings for Rust errors | |
9 | //! |
|
9 | //! | |
10 | //! [`GraphError`] exposes `hg::GraphError` as a subclass of `ValueError` |
|
10 | //! [`GraphError`] exposes `hg::GraphError` as a subclass of `ValueError` | |
|
11 | //! but some variants of `hg::GraphError` can be converted directly to other | |||
|
12 | //! existing Python exceptions if appropriate. | |||
11 | //! |
|
13 | //! | |
12 | //! [`GraphError`]: struct.GraphError.html |
|
14 | //! [`GraphError`]: struct.GraphError.html | |
13 | use cpython::exc::ValueError; |
|
15 | use cpython::exc::ValueError; | |
@@ -22,6 +24,15 b' impl GraphError {' | |||||
22 | hg::GraphError::ParentOutOfRange(r) => { |
|
24 | hg::GraphError::ParentOutOfRange(r) => { | |
23 | GraphError::new(py, ("ParentOutOfRange", r)) |
|
25 | GraphError::new(py, ("ParentOutOfRange", r)) | |
24 | } |
|
26 | } | |
|
27 | hg::GraphError::WorkingDirectoryUnsupported => { | |||
|
28 | match py | |||
|
29 | .import("mercurial.error") | |||
|
30 | .and_then(|m| m.get(py, "WdirUnsupported")) | |||
|
31 | { | |||
|
32 | Err(e) => e, | |||
|
33 | Ok(cls) => PyErr::from_instance(py, cls), | |||
|
34 | } | |||
|
35 | } | |||
25 | } |
|
36 | } | |
26 | } |
|
37 | } | |
27 | } |
|
38 | } |
General Comments 0
You need to be logged in to leave comments.
Login now