Skip to content

Commit 8661082

Browse files
committed
Do not crash if l10n cannot connect to D-Bus
1 parent e6adf05 commit 8661082

File tree

2 files changed

+14
-8
lines changed

2 files changed

+14
-8
lines changed

rust/agama-l10n/src/start.rs

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,6 @@ use agama_utils::{
3131
pub enum Error {
3232
#[error(transparent)]
3333
Service(#[from] service::Error),
34-
#[error(transparent)]
35-
Monitor(#[from] monitor::Error),
3634
}
3735

3836
/// Starts the localization service.
@@ -53,8 +51,17 @@ pub async fn start(
5351
let model = Model::from_system()?;
5452
let service = Service::new(model, issues, events);
5553
let handler = actor::spawn(service);
56-
let monitor = Monitor::new(handler.clone()).await?;
57-
monitor::spawn(monitor);
54+
55+
match Monitor::new(handler.clone()).await {
56+
Ok(monitor) => monitor::spawn(monitor),
57+
Err(error) => {
58+
tracing::error!(
59+
"Could not launch the l10n monitor, therefore changes from systemd will be ignored. \
60+
The original error was {error}"
61+
);
62+
}
63+
}
64+
5865
Ok(handler)
5966
}
6067

rust/agama-server/src/server/web.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@ use agama_utils::{
3131
},
3232
question,
3333
};
34-
use anyhow;
3534
use axum::{
3635
extract::State,
3736
response::{IntoResponse, Response},
@@ -72,17 +71,17 @@ type ServerResult<T> = Result<T, Error>;
7271
///
7372
/// * `events`: channel to send events to the websocket.
7473
/// * `dbus`: connection to Agama's D-Bus server. If it is not given, those features
75-
/// that require to connect to the Agama's D-Bus server won't work.
74+
/// that require to connect to the Agama's D-Bus server won't work.
7675
pub async fn server_service(
7776
events: event::Sender,
7877
dbus: Option<zbus::Connection>,
7978
) -> Result<Router, ServiceError> {
8079
let questions = question::start(events.clone())
8180
.await
82-
.map_err(|e| anyhow::Error::new(e))?;
81+
.map_err(anyhow::Error::msg)?;
8382
let manager = manager::start(questions.clone(), events, dbus)
8483
.await
85-
.map_err(|e| anyhow::Error::new(e))?;
84+
.map_err(anyhow::Error::msg)?;
8685

8786
let state = ServerState { manager, questions };
8887

0 commit comments

Comments
 (0)