Mercurial > public > mercurial-scm > hg-stable
annotate rust/hg-cpython/src/exceptions.rs @ 41184:dcf818267bc1
rust-cpython: rustdoc improvements
By default, `cargo doc` builds the documentation for public
constructs only, so we make public those that can. Since `cindex`
is not safe, we keep it private.
Unfortunately, the macro syntax of rust-cpython doesn't allow us
to document the classes directly, so we resort to do that at
the module level.
Differential Revision: https://phab.mercurial-scm.org/D5546
author | Georges Racinet <georges.racinet@octobus.net> |
---|---|
date | Sat, 22 Dec 2018 11:38:03 +0100 |
parents | 5532823e8c18 |
children | ee943a920606 |
rev | line source |
---|---|
41184
dcf818267bc1
rust-cpython: rustdoc improvements
Georges Racinet <georges.racinet@octobus.net>
parents:
40978
diff
changeset
|
1 // ancestors.rs |
dcf818267bc1
rust-cpython: rustdoc improvements
Georges Racinet <georges.racinet@octobus.net>
parents:
40978
diff
changeset
|
2 // |
dcf818267bc1
rust-cpython: rustdoc improvements
Georges Racinet <georges.racinet@octobus.net>
parents:
40978
diff
changeset
|
3 // Copyright 2018 Georges Racinet <gracinet@anybox.fr> |
dcf818267bc1
rust-cpython: rustdoc improvements
Georges Racinet <georges.racinet@octobus.net>
parents:
40978
diff
changeset
|
4 // |
dcf818267bc1
rust-cpython: rustdoc improvements
Georges Racinet <georges.racinet@octobus.net>
parents:
40978
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:
40978
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:
40978
diff
changeset
|
7 |
dcf818267bc1
rust-cpython: rustdoc improvements
Georges Racinet <georges.racinet@octobus.net>
parents:
40978
diff
changeset
|
8 //! Bindings for Rust errors |
dcf818267bc1
rust-cpython: rustdoc improvements
Georges Racinet <georges.racinet@octobus.net>
parents:
40978
diff
changeset
|
9 //! |
dcf818267bc1
rust-cpython: rustdoc improvements
Georges Racinet <georges.racinet@octobus.net>
parents:
40978
diff
changeset
|
10 //! [`GraphError`] exposes `hg::GraphError` as a subclass of `ValueError` |
dcf818267bc1
rust-cpython: rustdoc improvements
Georges Racinet <georges.racinet@octobus.net>
parents:
40978
diff
changeset
|
11 //! |
dcf818267bc1
rust-cpython: rustdoc improvements
Georges Racinet <georges.racinet@octobus.net>
parents:
40978
diff
changeset
|
12 //! [`GraphError`]: struct.GraphError.html |
40978
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 } |