[cache_check (rust)] Do not remap ArrayErrors to keep the error context

This commit is contained in:
Ming-Hung Tsai
2021-04-15 19:39:31 +08:00
parent 9b4a0607ea
commit 95dee9f66d
2 changed files with 43 additions and 21 deletions

View File

@@ -1,6 +1,7 @@
use nom::{multi::count, number::complete::*, IResult};
use thiserror::Error;
use crate::checksum;
use crate::io_engine::BLOCK_SIZE;
use crate::pdata::btree;
use crate::pdata::unpack::Unpack;
@@ -94,7 +95,14 @@ fn convert_result<'a, V>(path: &[u64], r: IResult<&'a [u8], V>) -> Result<(&'a [
}
pub fn unpack_array_block<V: Unpack>(path: &[u64], data: &[u8]) -> Result<ArrayBlock<V>> {
// TODO: collect errors
let bt = checksum::metadata_block_type(data);
if bt != checksum::BT::ARRAY {
return Err(array_block_err(
path,
&format!("checksum failed for array block {}, {:?}", path.last().unwrap(), bt)
));
}
let (i, header) =
ArrayBlockHeader::unpack(data).map_err(|_| array_block_err(
path,