# HG changeset patch # User Raphaël Gomès # Date 2024-10-02 22:31:25 # Node ID db5c202eff36ffd1c915a60b04d88ca15ac95da7 # Parent 503b7688f05723e086a27539b8ad89c37ff0ee01 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. diff --git a/rust/hg-core/src/dirstate/parsers.rs b/rust/hg-core/src/dirstate/parsers.rs --- a/rust/hg-core/src/dirstate/parsers.rs +++ b/rust/hg-core/src/dirstate/parsers.rs @@ -23,8 +23,13 @@ type ParseResult<'a> = ( 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) }