diff rust/hg-pyo3/src/exceptions.rs @ 52784:5e3e8876fd9e

rust-pyo3-revlog: index and nodetree read accessor helpers These are similar to what Python calls context managers: they enclose neatly the intermediate `self_ref` and will allow writing caller code that focuses on its own application logic.
author Georges Racinet <georges.racinet@cloudcrane.io>
date Wed, 25 Dec 2024 15:38:18 +0100
parents 827889802d11
children 4e34e8fd46d4
line wrap: on
line diff
--- a/rust/hg-pyo3/src/exceptions.rs	Sun Dec 22 20:26:57 2024 +0100
+++ b/rust/hg-pyo3/src/exceptions.rs	Wed Dec 25 15:38:18 2024 +0100
@@ -42,10 +42,10 @@
     PyRuntimeError::new_err(format!("In Rust PyO3 bindings: {e}"))
 }
 
-/// Submodule to hold Mercurial errors defined on the Python side
-///
-/// This is better for clarity, as many hg-core errors have the same names
-/// as their Python world counterparts
+pub fn map_try_lock_error<T>(e: std::sync::TryLockError<T>) -> PyErr {
+    PyRuntimeError::new_err(format!("In Rust PyO3 bindings: {e}"))
+}
+
 pub mod mercurial_py_errors {
     pyo3::import_exception!(mercurial.error, RevlogError);
 }