mirror of
https://github.com/esp-rs/esp-hal.git
synced 2025-09-27 12:20:56 +00:00
Implement Error
trait more (#4097)
* Implement `Error` trait more fmt * oi * fix
This commit is contained in:
parent
d16b68396c
commit
b01f444822
@ -140,6 +140,8 @@ impl core::fmt::Display for TxError {
|
||||
}
|
||||
}
|
||||
|
||||
impl core::error::Error for TxError {}
|
||||
|
||||
#[instability::unstable]
|
||||
impl embedded_io::Error for TxError {
|
||||
fn kind(&self) -> embedded_io::ErrorKind {
|
||||
|
@ -47,6 +47,16 @@ impl Error for BleConnectorError {
|
||||
}
|
||||
}
|
||||
|
||||
impl core::error::Error for BleConnectorError {}
|
||||
|
||||
impl core::fmt::Display for BleConnectorError {
|
||||
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
|
||||
match self {
|
||||
BleConnectorError::Unknown => write!(f, "Unknown BLE error occured"),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl ErrorType for BleConnector<'_> {
|
||||
type Error = BleConnectorError;
|
||||
}
|
||||
|
@ -354,6 +354,35 @@ pub enum InitializationError {
|
||||
Adc2IsUsed,
|
||||
}
|
||||
|
||||
impl core::error::Error for InitializationError {}
|
||||
|
||||
impl core::fmt::Display for InitializationError {
|
||||
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
|
||||
match self {
|
||||
InitializationError::General(e) => write!(f, "A general error {e} occurred"),
|
||||
#[cfg(feature = "wifi")]
|
||||
InitializationError::WifiError(e) => {
|
||||
write!(f, "Wi-Fi driver related error occured: {e}")
|
||||
}
|
||||
InitializationError::WrongClockConfig => {
|
||||
write!(f, "The current CPU clock frequency is too low")
|
||||
}
|
||||
InitializationError::InterruptsDisabled => write!(
|
||||
f,
|
||||
"Attempted to initialize while interrupts are disabled (Unsupported)"
|
||||
),
|
||||
InitializationError::SchedulerNotInitialized => {
|
||||
write!(f, "The scheduler is not initialized")
|
||||
}
|
||||
#[cfg(esp32)]
|
||||
InitializationError::Adc2IsUsed => write!(
|
||||
f,
|
||||
"ADC2 cannot be used with `radio` functionality on `esp32`"
|
||||
),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(feature = "wifi")]
|
||||
impl From<WifiError> for InitializationError {
|
||||
fn from(value: WifiError) -> Self {
|
||||
|
Loading…
x
Reference in New Issue
Block a user