implement error view which displays all error on the display
This commit was merged in pull request #48.
This commit is contained in:
@@ -1,5 +1,7 @@
|
||||
use alloc::collections::BTreeMap;
|
||||
use alloc::vec::Vec;
|
||||
use core::error::Error;
|
||||
use core::fmt::Display;
|
||||
|
||||
use binary_serde::{BinarySerde, DeserializeError, Endianness};
|
||||
|
||||
@@ -67,7 +69,19 @@ impl AllocationTableEntry {
|
||||
pub enum CardStoreError {
|
||||
Store(FlashStoreError),
|
||||
CorruptedEntry(DeserializeError),
|
||||
NoEntry,
|
||||
NoEntry(u32),
|
||||
}
|
||||
|
||||
impl Error for CardStoreError {}
|
||||
|
||||
impl Display for CardStoreError {
|
||||
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
|
||||
match self {
|
||||
CardStoreError::Store(e) => e.fmt(f),
|
||||
CardStoreError::CorruptedEntry(e) => e.fmt(f),
|
||||
CardStoreError::NoEntry(uuid) => write!(f, "No Card Entry\nuuid: 0x{uuid:x}"),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl From<FlashStoreError> for CardStoreError {
|
||||
@@ -129,7 +143,7 @@ impl CardStore {
|
||||
let entry = self
|
||||
.allocation_table
|
||||
.get(&uuid)
|
||||
.ok_or(CardStoreError::NoEntry)?;
|
||||
.ok_or(CardStoreError::NoEntry(uuid))?;
|
||||
|
||||
let mut raw_card: [u8; size_of::<RawCard>()] = [0; size_of::<RawCard>()];
|
||||
self.store.read(entry.offset, &mut raw_card).await?;
|
||||
|
||||
Reference in New Issue
Block a user