Mercurial > hg
changeset 52052:db5c202eff36
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.
author | Raphaël Gomès <rgomes@octobus.net> |
---|---|
date | Thu, 03 Oct 2024 00:31:25 +0200 |
parents | 503b7688f057 |
children | af54626bf358 |
files | rust/hg-core/src/dirstate/parsers.rs |
diffstat | 1 files changed, 7 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- 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) }