1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
use crate::LoraError;

#[derive(Debug, derive_more::From)]
pub enum Error {
    CriticalDevice,
    #[from]
    Lora(LoraError),
    Response(i8),
}

impl defmt::Format for Error {
    fn format(&self, fmt: defmt::Formatter) {
        match self {
            Self::CriticalDevice => {
                defmt::write!(fmt, "Failed to initialize a critical peripheral device")
            }
            Self::Lora(e) => defmt::write!(fmt, "Lora Error: {}", &e),
            Self::Response(ec) => defmt::write!(fmt, "Received ERROR({}) response from LoRa", ec),
        }
    }
}