mirror of
https://gitlab.steamos.cloud/holo/steamos-manager.git
synced 2025-07-16 03:06:47 -04:00
main: Generalize how to convert errors into zbus errors
This commit is contained in:
parent
eb5fbc8e39
commit
f6dd8ce3dd
2 changed files with 30 additions and 23 deletions
15
src/main.rs
15
src/main.rs
|
@ -5,7 +5,7 @@
|
|||
* SPDX-License-Identifier: MIT
|
||||
*/
|
||||
|
||||
use anyhow::{anyhow, bail, Error, Result};
|
||||
use anyhow::{anyhow, bail, Result};
|
||||
use std::path::{Path, PathBuf};
|
||||
use tokio::fs::File;
|
||||
use tokio::io::AsyncWriteExt;
|
||||
|
@ -132,12 +132,19 @@ async fn reload() -> Result<()> {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn anyhow_to_zbus(error: Error) -> zbus::Error {
|
||||
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 anyhow_to_zbus_fdo(error: Error) -> zbus::fdo::Error {
|
||||
zbus::fdo::Error::Failed(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()),
|
||||
}
|
||||
}
|
||||
|
||||
async fn create_connection() -> Result<Connection> {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue