From 94442423a9159a8cdaa60d4a6e7b7e13c95a6ebb Mon Sep 17 00:00:00 2001 From: Carter Green Date: Fri, 5 Jan 2024 14:20:07 -0600 Subject: [PATCH] MOD: Improve `RecordRef::get` panic message --- CHANGELOG.md | 2 ++ rust/dbn/src/record_ref.rs | 4 +++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 56cdd35..e15f297 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -22,6 +22,8 @@ - Added Python type definition for `Metadata.__init__` - Added `metadata_mut` method to decoders to get a mutable reference to the decoded metadata +- Improved panic message on `RecordRef::get` when length doesn't match expected to be + actionable - Added `encode::ZSTD_COMPRESSION_LEVEL` constant ### Breaking changes diff --git a/rust/dbn/src/record_ref.rs b/rust/dbn/src/record_ref.rs index d26db92..b0841d1 100644 --- a/rust/dbn/src/record_ref.rs +++ b/rust/dbn/src/record_ref.rs @@ -77,7 +77,9 @@ impl<'a> RecordRef<'a> { if self.has::() { assert!( self.record_size() >= mem::size_of::(), - "Malformed record. Expected length of at least {} bytes, found {} bytes", + "Malformed `{}` record: expected length of at least {} bytes, found {} bytes. \ + Confirm the DBN version in the Metadata header and the version upgrade policy", + std::any::type_name::(), mem::size_of::(), self.record_size() );