implement error view which displays all error on the display

This commit was merged in pull request #48.
This commit is contained in:
2026-08-29 20:19:14 +00:00
parent a31c818b37
commit ef10eec216
17 changed files with 316 additions and 92 deletions
+16 -2
View File
@@ -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?;