Throw error for unexpected input length for Fingerprint.

This commit is contained in:
Heiko Schaefer 2021-09-07 15:00:22 +02:00
parent 6cfe340d2b
commit 891b57df06

View file

@ -28,11 +28,13 @@ impl TryFrom<&[u8]> for Fingerprint {
input.len() input.len()
); );
// FIXME: return error if input.len() == 20 {
assert_eq!(input.len(), 20); let array: [u8; 20] = input.try_into().unwrap();
Ok(array.into())
let array: [u8; 20] = input.try_into().unwrap(); } else {
Ok(array.into()) Err(anyhow!("Unexpected fingerprint length {}", input.len())
.into())
}
} }
} }