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

23
src/error.rs Normal file
View file

@ -0,0 +1,23 @@
/*
* Copyright © 2023 Collabora Ltd.
* Copyright © 2024 Valve Software
*
* SPDX-License-Identifier: MIT
*/
use zbus::fdo;
pub fn to_zbus_fdo_error<S: ToString>(error: S) -> fdo::Error {
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) -> fdo::Error {
match error {
zbus::Error::FDO(error) => *error,
error => fdo::Error::Failed(error.to_string()),
}
}