Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions rust/agama-lib/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,10 @@ use zbus;

#[derive(Error, Debug)]
pub enum ServiceError {
#[error("D-Bus service error: {0}")]
#[error("D-Bus service error")]
DBus(#[from] zbus::Error),
#[error("Could not connect to Agama bus at '{0}'")]
DBusConnectionError(String, #[source] zbus::Error),
#[error("Unknown product '{0}'. Available products: '{1:?}'")]
UnknownProduct(String, Vec<String>),
// it's fine to say only "Error" because the original
Expand All @@ -24,7 +26,7 @@ pub enum ProfileError {
Unreachable(#[from] curl::Error),
#[error("Jsonnet evaluation failed:\n{0}")]
EvaluationError(String),
#[error("I/O error: '{0}'")]
#[error("I/O error")]
InputOutputError(#[from] io::Error),
#[error("The profile is not a valid JSON file")]
FormatError(#[from] serde_json::Error),
Expand Down
3 changes: 1 addition & 2 deletions rust/agama-lib/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ mod store;
pub use store::Store;

use crate::error::ServiceError;
use anyhow::Context;

const ADDRESS: &str = "unix:path=/run/agama/bus";

Expand All @@ -52,6 +51,6 @@ pub async fn connection_to(address: &str) -> Result<zbus::Connection, ServiceErr
let connection = zbus::ConnectionBuilder::address(address)?
.build()
.await
.context(format!("Connecting to Agama bus at {ADDRESS}"))?;
.map_err(|e| ServiceError::DBusConnectionError(ADDRESS.to_string(), e))?;
Ok(connection)
}