error: Split out error utils into a separate module

This commit is contained in:
Vicki Pfau 2024-05-08 14:53:26 -07:00
parent f4247de8c1
commit fd500229d6
5 changed files with 29 additions and 18 deletions

View file

@ -17,6 +17,7 @@ use tracing::{info, warn};
mod cec;
mod daemon;
mod ds_inhibit;
mod error;
mod hardware;
mod manager;
mod power;
@ -135,21 +136,6 @@ async fn reload() -> Result<()> {
}
}
pub fn to_zbus_fdo_error<S: ToString>(error: S) -> zbus::fdo::Error {
zbus::fdo::Error::Failed(error.to_string())
}
pub fn to_zbus_error<S: ToString>(error: S) -> zbus::Error {
zbus::Error::Failure(error.to_string())
}
pub fn zbus_to_zbus_fdo(error: zbus::Error) -> zbus::fdo::Error {
match error {
zbus::Error::FDO(error) => *error,
error => zbus::fdo::Error::Failed(error.to_string()),
}
}
#[cfg(test)]
mod test {
use crate::testing;