author | Georges Racinet <georges.racinet@octobus.net> |
Sat, 22 Dec 2018 11:38:03 +0100 | |
changeset 41184 | dcf818267bc1 |
parent 40965 | 5532823e8c18 |
child 41349 | ee943a920606 |
permissions | -rw-r--r-- |
41184
dcf818267bc1
rust-cpython: rustdoc improvements
Georges Racinet <georges.racinet@octobus.net>
parents:
40965
diff
changeset
|
1 |
// ancestors.rs |
dcf818267bc1
rust-cpython: rustdoc improvements
Georges Racinet <georges.racinet@octobus.net>
parents:
40965
diff
changeset
|
2 |
// |
dcf818267bc1
rust-cpython: rustdoc improvements
Georges Racinet <georges.racinet@octobus.net>
parents:
40965
diff
changeset
|
3 |
// Copyright 2018 Georges Racinet <gracinet@anybox.fr> |
dcf818267bc1
rust-cpython: rustdoc improvements
Georges Racinet <georges.racinet@octobus.net>
parents:
40965
diff
changeset
|
4 |
// |
dcf818267bc1
rust-cpython: rustdoc improvements
Georges Racinet <georges.racinet@octobus.net>
parents:
40965
diff
changeset
|
5 |
// This software may be used and distributed according to the terms of the |
dcf818267bc1
rust-cpython: rustdoc improvements
Georges Racinet <georges.racinet@octobus.net>
parents:
40965
diff
changeset
|
6 |
// GNU General Public License version 2 or any later version. |
dcf818267bc1
rust-cpython: rustdoc improvements
Georges Racinet <georges.racinet@octobus.net>
parents:
40965
diff
changeset
|
7 |
|
dcf818267bc1
rust-cpython: rustdoc improvements
Georges Racinet <georges.racinet@octobus.net>
parents:
40965
diff
changeset
|
8 |
//! Bindings for Rust errors |
dcf818267bc1
rust-cpython: rustdoc improvements
Georges Racinet <georges.racinet@octobus.net>
parents:
40965
diff
changeset
|
9 |
//! |
dcf818267bc1
rust-cpython: rustdoc improvements
Georges Racinet <georges.racinet@octobus.net>
parents:
40965
diff
changeset
|
10 |
//! [`GraphError`] exposes `hg::GraphError` as a subclass of `ValueError` |
dcf818267bc1
rust-cpython: rustdoc improvements
Georges Racinet <georges.racinet@octobus.net>
parents:
40965
diff
changeset
|
11 |
//! |
dcf818267bc1
rust-cpython: rustdoc improvements
Georges Racinet <georges.racinet@octobus.net>
parents:
40965
diff
changeset
|
12 |
//! [`GraphError`]: struct.GraphError.html |
40965
5532823e8c18
rust-cpython: start cpython crate bindings
Georges Racinet <gracinet@anybox.fr>
parents:
diff
changeset
|
13 |
use cpython::exc::ValueError; |
5532823e8c18
rust-cpython: start cpython crate bindings
Georges Racinet <gracinet@anybox.fr>
parents:
diff
changeset
|
14 |
use cpython::{PyErr, Python}; |
5532823e8c18
rust-cpython: start cpython crate bindings
Georges Racinet <gracinet@anybox.fr>
parents:
diff
changeset
|
15 |
use hg; |
5532823e8c18
rust-cpython: start cpython crate bindings
Georges Racinet <gracinet@anybox.fr>
parents:
diff
changeset
|
16 |
|
5532823e8c18
rust-cpython: start cpython crate bindings
Georges Racinet <gracinet@anybox.fr>
parents:
diff
changeset
|
17 |
py_exception!(rustext, GraphError, ValueError); |
5532823e8c18
rust-cpython: start cpython crate bindings
Georges Racinet <gracinet@anybox.fr>
parents:
diff
changeset
|
18 |
|
5532823e8c18
rust-cpython: start cpython crate bindings
Georges Racinet <gracinet@anybox.fr>
parents:
diff
changeset
|
19 |
impl GraphError { |
5532823e8c18
rust-cpython: start cpython crate bindings
Georges Racinet <gracinet@anybox.fr>
parents:
diff
changeset
|
20 |
pub fn pynew(py: Python, inner: hg::GraphError) -> PyErr { |
5532823e8c18
rust-cpython: start cpython crate bindings
Georges Racinet <gracinet@anybox.fr>
parents:
diff
changeset
|
21 |
match inner { |
5532823e8c18
rust-cpython: start cpython crate bindings
Georges Racinet <gracinet@anybox.fr>
parents:
diff
changeset
|
22 |
hg::GraphError::ParentOutOfRange(r) => { |
5532823e8c18
rust-cpython: start cpython crate bindings
Georges Racinet <gracinet@anybox.fr>
parents:
diff
changeset
|
23 |
GraphError::new(py, ("ParentOutOfRange", r)) |
5532823e8c18
rust-cpython: start cpython crate bindings
Georges Racinet <gracinet@anybox.fr>
parents:
diff
changeset
|
24 |
} |
5532823e8c18
rust-cpython: start cpython crate bindings
Georges Racinet <gracinet@anybox.fr>
parents:
diff
changeset
|
25 |
} |
5532823e8c18
rust-cpython: start cpython crate bindings
Georges Racinet <gracinet@anybox.fr>
parents:
diff
changeset
|
26 |
} |
5532823e8c18
rust-cpython: start cpython crate bindings
Georges Racinet <gracinet@anybox.fr>
parents:
diff
changeset
|
27 |
} |