rust-parsers: use the same error message as with the higher-level code
This can happen at two places, but it's not really enough time to justify it
being refactored. Let's ensure we have the same error message, the newer one
being slightly more helpful.
--- a/rust/hg-core/src/dirstate/parsers.rs Thu Oct 03 01:52:44 2024 +0200
+++ b/rust/hg-core/src/dirstate/parsers.rs Thu Oct 03 00:31:25 2024 +0200
@@ -23,8 +23,13 @@
pub fn parse_dirstate_parents(
contents: &[u8],
) -> Result<&DirstateParents, HgError> {
- let (parents, _rest) = DirstateParents::from_bytes(contents)
- .map_err(|_| HgError::corrupted("Too little data for dirstate."))?;
+ let contents_len = contents.len();
+ let (parents, _rest) =
+ DirstateParents::from_bytes(contents).map_err(|_| {
+ HgError::corrupted(format!(
+ "Too little data for dirstate: {contents_len} bytes.",
+ ))
+ })?;
Ok(parents)
}