holochain_integrity_types/entry/
error.rs

1use super::*;
2
3/// Errors involving app entry creation
4#[derive(Debug, Clone, PartialEq)]
5pub enum EntryError {
6    /// The entry is too large to be created
7    EntryTooLarge(usize),
8
9    /// SerializedBytes passthrough
10    SerializedBytes(SerializedBytesError),
11}
12
13impl std::error::Error for EntryError {
14    fn source(&self) -> Option<&(dyn std::error::Error + 'static)> {
15        match self {
16            EntryError::EntryTooLarge(_) => None,
17            EntryError::SerializedBytes(e) => e.source(),
18        }
19    }
20}
21
22impl From<SerializedBytesError> for EntryError {
23    fn from(e: SerializedBytesError) -> Self {
24        Self::SerializedBytes(e)
25    }
26}
27
28impl core::fmt::Display for EntryError {
29    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
30        match self {
31            EntryError::EntryTooLarge(bytes)=> write!(
32                f,
33                "Attempted to create an Entry whose size exceeds the limit.\nEntry size: {}\nLimit: {}",
34                bytes,
35                ENTRY_SIZE_LIMIT
36            ),
37            EntryError::SerializedBytes(s) => s.fmt(f),
38        }
39    }
40}