##// END OF EJS Templates
rust-pyo3: generic borrows of UnsafePyLeaked with error treatment...
rust-pyo3: generic borrows of UnsafePyLeaked with error treatment Maybe we will find later a more pleasant way to express safety. Meanwhile, these helpers are useful because of the proper error propagation, and will help to avoid too much cruft in the caller code.

File last commit:

r53309:6e8ba528 default
r53427:73655156 default
Show More
exceptions.rs
34 lines | 1.1 KiB | application/rls-services+xml | RustLexer
use pyo3::exceptions::PyValueError;
use pyo3::import_exception;
use pyo3::{create_exception, PyErr};
use crate::revision::PyRevision;
create_exception!(pyo3_rustext, GraphError, PyValueError);
import_exception!(mercurial.error, WdirUnsupported);
impl GraphError {
pub fn from_hg(inner: hg::GraphError) -> PyErr {
match inner {
hg::GraphError::ParentOutOfRange(r) => {
GraphError::new_err(("ParentOutOfRange", PyRevision(r.0)))
}
}
}
pub fn from_vcsgraph(inner: vcsgraph::graph::GraphReadError) -> PyErr {
match inner {
vcsgraph::graph::GraphReadError::InconsistentGraphData => {
GraphError::new_err("InconsistentGraphData")
}
vcsgraph::graph::GraphReadError::InvalidKey => {
GraphError::new_err("ParentOutOfRange")
}
vcsgraph::graph::GraphReadError::KeyedInvalidKey(r) => {
GraphError::new_err(("ParentOutOfRange", r))
}
vcsgraph::graph::GraphReadError::WorkingDirectoryUnsupported => {
WdirUnsupported::new_err(())
}
}
}
}