From 9f8bca26d5336762bb75fb89c6552a7a83c9b2d8 Mon Sep 17 00:00:00 2001 From: Jeremy Whiting Date: Wed, 25 Jun 2025 09:42:35 -0600 Subject: [PATCH 1/3] Add some context of which file is missing. In one case where platform.toml is not where we expect add to the os error 2 which file we were looking for. --- src/platform.rs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/platform.rs b/src/platform.rs index cc4f897..975f353 100644 --- a/src/platform.rs +++ b/src/platform.rs @@ -5,6 +5,8 @@ * SPDX-License-Identifier: MIT */ +#[cfg(not(test))] +use anyhow::Context; use anyhow::Result; use nix::errno::Errno; use nix::unistd::{access, AccessFlags}; @@ -173,7 +175,10 @@ impl FormatDeviceConfig { impl PlatformConfig { #[cfg(not(test))] async fn load() -> Result> { - let config = read_to_string("/usr/share/steamos-manager/platform.toml").await?; + let path = "/usr/share/steamos-manager/platform.toml"; + let config = read_to_string(path) + .await + .with_context(|| format!("Failed to read {path}"))?; Ok(Some(toml::from_str(config.as_ref())?)) } From 779d468e053fbcab3aad9f25241e1c6db4362a6e Mon Sep 17 00:00:00 2001 From: Jeremy Whiting Date: Wed, 25 Jun 2025 10:37:57 -0600 Subject: [PATCH 2/3] Also add context when unable to read orca config file. --- src/screenreader.rs | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/src/screenreader.rs b/src/screenreader.rs index d88e532..b438923 100644 --- a/src/screenreader.rs +++ b/src/screenreader.rs @@ -6,7 +6,7 @@ */ use ::sysinfo::System; -use anyhow::{anyhow, bail, ensure, Result}; +use anyhow::{anyhow, bail, ensure, Context, Result}; use gio::{prelude::SettingsExt, Settings}; use input_linux::Key; use lazy_static::lazy_static; @@ -327,7 +327,10 @@ impl<'dbus> OrcaManager<'dbus> { async fn set_orca_enabled(&mut self, enabled: bool) -> Result<()> { // Change json file - let data = read_to_string(self.settings_path()?).await?; + let path = self.settings_path()?; + let data = read_to_string(&path) + .await + .with_context(|| format!("Unable to read from {}", path.display()))?; let mut json: Value = serde_json::from_str(&data)?; let general = json @@ -345,8 +348,10 @@ impl<'dbus> OrcaManager<'dbus> { } async fn load_values(&mut self) -> Result<()> { - debug!("Loading orca values from user-settings.conf"); - let data = read_to_string(self.settings_path()?).await?; + let path = self.settings_path()?; + let data = read_to_string(&path) + .await + .with_context(|| format!("Unable to read from {}", path.display()))?; let json: Value = serde_json::from_str(&data)?; let Some(default_voice) = json @@ -405,7 +410,10 @@ impl<'dbus> OrcaManager<'dbus> { } else { bail!("Invalid orca option {option}"); } - let data = read_to_string(self.settings_path()?).await?; + let path = self.settings_path()?; + let data = read_to_string(&path) + .await + .with_context(|| format!("Unable to read from {}", path.display()))?; let mut json: Value = serde_json::from_str(&data)?; let profiles = json From 29dbb625914667fa9ec432ec97b0a03d3cba7d85 Mon Sep 17 00:00:00 2001 From: Jeremy Whiting Date: Wed, 25 Jun 2025 11:17:45 -0600 Subject: [PATCH 3/3] Remove tracing::debug from screenreader.rs since it's unused. --- src/screenreader.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/screenreader.rs b/src/screenreader.rs index b438923..8e8e4ef 100644 --- a/src/screenreader.rs +++ b/src/screenreader.rs @@ -20,7 +20,7 @@ use std::ops::RangeInclusive; use std::path::PathBuf; use strum::{Display, EnumString}; use tokio::fs::{read_to_string, write}; -use tracing::{debug, error, info, trace, warn}; +use tracing::{error, info, trace, warn}; #[cfg(not(test))] use xdg::BaseDirectories; use zbus::Connection;