chore: better error reporting

This commit is contained in:
Ilya Zlobintsev
2023-12-21 19:05:04 +02:00
parent 1a12316cfe
commit 4f163fb323
5 changed files with 8 additions and 7 deletions

4
Cargo.lock generated
View File

@@ -41,9 +41,9 @@ dependencies = [
[[package]]
name = "amdgpu-sysfs"
version = "0.12.5"
version = "0.12.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "59af03e9a4fe381f4ee8b2404ef22513a626010c6dc7e5d225cdbf99d0a74022"
checksum = "99b0082f43b383acea8205b8f86c121a24d430ee53be54cdb30a1b52d6cf425c"
dependencies = [
"enum_dispatch",
"serde",

View File

@@ -561,7 +561,8 @@ impl GpuController {
self.handle
.set_clocks_table(&table)
.context("Could not write clocks table")?;
.context("Could not write clocks table")
.with_context(|| format!("Clocks table commands: {:?}", table.get_commands()))?;
}
for (kind, states) in &config.power_states {

View File

@@ -99,10 +99,10 @@ impl<'a> Handler {
Ok(apply_timer)
}
Err(apply_err) => {
error!("could not apply settings: {apply_err:#}");
error!("could not apply settings: {apply_err:?}");
match controller.apply_config(&gpu_config).await {
Ok(()) => Err(apply_err.context("Could not apply settings")),
Err(err) => Err(anyhow!("Could not apply settings, and could not reset to default settings: {err:#}")),
Err(err) => Err(anyhow!("Could not apply settings, and could not reset to default settings: {err:?}")),
}
}
}

View File

@@ -60,7 +60,7 @@ pub async fn handle_stream(stream: UnixStream, handler: Handler) -> anyhow::Resu
let response = match maybe_request {
Ok(request) => match handle_request(request, &handler).await {
Ok(response) => response,
Err(error) => serde_json::to_vec(&Response::<()>::Error(format!("{error:#}")))?,
Err(error) => serde_json::to_vec(&Response::<()>::Error(format!("{error:?}")))?,
},
Err(error) => serde_json::to_vec(&Response::<()>::Error(format!(
"Failed to deserialize request: {error}"

View File

@@ -7,7 +7,7 @@ edition = "2021"
args = ["clap"]
[dependencies]
amdgpu-sysfs = { version = "0.12.5", features = ["serde"] }
amdgpu-sysfs = { version = "0.12.6", features = ["serde"] }
serde = { version = "1.0", features = ["derive"] }
indexmap = { version = "*", features = ["serde"] }
clap = { version = "4.4.6", features = ["derive"], optional = true }