Skip to content

Commit

Permalink
Improve error message
Browse files Browse the repository at this point in the history
  • Loading branch information
Thoralf-M committed Jan 16, 2024
1 parent 1c5dc34 commit 1a52213
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
4 changes: 3 additions & 1 deletion sdk/src/types/block/output/feature/metadata.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,9 @@ fn verify_length_packable<const VERIFY: bool>(map: &MetadataBTreeMapPrefix) -> R
if !MetadataFeature::LENGTH_RANGE
.contains(&u16::try_from(len).map_err(|e| Error::InvalidMetadataFeature(e.to_string()))?)
{
return Err(Error::InvalidMetadataFeature(len.to_string()));
return Err(Error::InvalidMetadataFeature(format!(
"Out of bounds byte length: {len}"
)));
}
}
Ok(())
Expand Down
2 changes: 1 addition & 1 deletion sdk/tests/types/output/feature/metadata.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,6 @@ fn unpack_invalid_order() {
fn unpack_invalid_length() {
assert!(matches!(
MetadataFeature::unpack_verified([vec![1, 0, 1, 33, 0, 32], vec![0u8; 8192]].concat(), &()),
Err(UnpackError::Packable(Error::InvalidMetadataFeature(len))) if &len == "8199"
Err(UnpackError::Packable(Error::InvalidMetadataFeature(len))) if &len == "Out of bounds byte length: 8199"
));
}

0 comments on commit 1a52213

Please sign in to comment.