chore(tvix/nix-compat): include invalid hashes in SRI hash error

Change-Id: I379b18cb07da0988f8ce4934976ae7d6566d6bb5
Reviewed-on: https://cl.tvl.fyi/c/depot/+/8210
Autosubmit: tazjin <tazjin@tvl.su>
Tested-by: BuildkiteCI
Reviewed-by: flokli <flokli@flokli.de>
This commit is contained in:
Vincent Ambo 2023-03-04 02:16:41 +03:00 committed by clbot
parent dfb8b7a266
commit 248f1c2151

View file

@ -61,8 +61,8 @@ fn hash_algo_length(hash_algo: &HashAlgo) -> usize {
pub enum Error {
#[error("invalid hash algo: {0}")]
InvalidAlgo(String),
#[error("invalid sri string")]
InvalidSRI,
#[error("invalid SRI string: {0}")]
InvalidSRI(String),
#[error("invalid encoded digest length '{0}' for algo {1}")]
InvalidEncodedDigestLength(usize, HashAlgo),
#[error("invalid base16 encoding: {0}")]
@ -155,7 +155,7 @@ pub fn from_sri_str(s: &str) -> Result<NixHash, Error> {
let idx = s.as_bytes().iter().position(|&e| e == b'-');
if idx.is_none() {
return Err(Error::InvalidSRI);
return Err(Error::InvalidSRI(s.to_string()));
}
let idx = idx.unwrap();