Mercurial > public > mercurial-scm > hg-stable
diff rust/hg-cpython/src/revlog.rs @ 49373:455fce57e89e stable
rust: don't swallow valuable error information
This helps when diagnosing corruption, and is in general good practice. The
information is here, valuable and can be used easily.
author | Rapha?l Gom?s <rgomes@octobus.net> |
---|---|
date | Wed, 18 May 2022 15:53:28 +0100 |
parents | aa88fb60ecb4 |
children | 58074252db3c |
line wrap: on
line diff
--- a/rust/hg-cpython/src/revlog.rs Wed May 18 09:50:39 2022 +0100 +++ b/rust/hg-cpython/src/revlog.rs Wed May 18 15:53:28 2022 +0100 @@ -107,7 +107,10 @@ String::from_utf8_lossy(node.data(py)).to_string() }; - let prefix = NodePrefix::from_hex(&node_as_string).map_err(|_| PyErr::new::<ValueError, _>(py, "Invalid node or prefix"))?; + let prefix = NodePrefix::from_hex(&node_as_string) + .map_err(|_| PyErr::new::<ValueError, _>( + py, format!("Invalid node or prefix '{}'", node_as_string)) + )?; nt.find_bin(idx, prefix) // TODO make an inner API returning the node directly