byteor_pipeline_backings_shm/
error.rs1use crate::sequenced_slots::SequencedSlotsError;
4
5#[derive(Debug)]
7pub enum BackingError {
8 Transport(byteor_transport_shm::Error),
10 TransportIndexbus(indexbus_transport_shm::Error),
12 Unsupported(&'static str),
14 Invalid(&'static str),
16 Core(indexbus_core::Error),
18
19 #[cfg(feature = "journal")]
21 Journal(indexbus_log::Error),
22
23 SequencedSlots(SequencedSlotsError),
25}
26
27impl core::fmt::Display for BackingError {
28 fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
29 match self {
30 BackingError::Transport(e) => write!(f, "transport error: {e}"),
31 BackingError::TransportIndexbus(e) => write!(f, "transport error: {e:?}"),
32 BackingError::Unsupported(s) => write!(f, "unsupported: {s}"),
33 BackingError::Invalid(s) => write!(f, "invalid: {s}"),
34 BackingError::Core(e) => write!(f, "core error: {e:?}"),
35 #[cfg(feature = "journal")]
36 BackingError::Journal(e) => write!(f, "journal error: {e}"),
37 BackingError::SequencedSlots(e) => write!(f, "sequenced-slots error: {e}"),
38 }
39 }
40}
41
42impl std::error::Error for BackingError {
43 fn source(&self) -> Option<&(dyn std::error::Error + 'static)> {
44 match self {
45 BackingError::Transport(e) => Some(e),
46 #[cfg(feature = "journal")]
47 BackingError::Journal(e) => Some(e),
48 _ => None,
49 }
50 }
51}
52
53impl From<byteor_transport_shm::Error> for BackingError {
54 fn from(value: byteor_transport_shm::Error) -> Self {
55 Self::Transport(value)
56 }
57}
58
59impl From<indexbus_transport_shm::Error> for BackingError {
60 fn from(value: indexbus_transport_shm::Error) -> Self {
61 Self::TransportIndexbus(value)
62 }
63}
64
65impl From<indexbus_core::Error> for BackingError {
66 fn from(value: indexbus_core::Error) -> Self {
67 Self::Core(value)
68 }
69}
70
71#[cfg(feature = "journal")]
72impl From<indexbus_log::Error> for BackingError {
73 fn from(value: indexbus_log::Error) -> Self {
74 Self::Journal(value)
75 }
76}
77
78impl From<SequencedSlotsError> for BackingError {
79 fn from(value: SequencedSlotsError) -> Self {
80 match value {
81 SequencedSlotsError::Full => BackingError::Core(indexbus_core::Error::Full),
82 other => BackingError::SequencedSlots(other),
83 }
84 }
85}